Skip to content

Commit

Permalink
z80retro: start fixing up the z80retro conversion to the new compiler
Browse files Browse the repository at this point in the history
This gets the SD card and boot sorted but console input is not happy
  • Loading branch information
EtchedPixels committed Dec 29, 2024
1 parent efabcc6 commit 9b17be6
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 11 deletions.
8 changes: 5 additions & 3 deletions Kernel/platform/platform-z80retro/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ image: bootblock
perl -lpe '$$_=hex' fuzix.tmpmap | paste -d" " - fuzix.tmpmap | sort -n | cut -d" " -f 2- >../../fuzix.map
../../tools/pack85 <../../fuzix.map fuzix.bin ../../fuzix.bin
# Attach the kernel to the boot block
cat boot-romwbw.bin ../../fuzix.bin >fuzix.romwbw
#cat boot-romwbw.bin ../../fuzix.bin >fuzix.romwbw

clean:
rm -f $(OBJS) $(JUNK) core *~
Expand All @@ -86,7 +86,9 @@ diskimage: image
dd if=$(FUZIX_ROOT)/Standalone/filesystem-src/parttab.40M of=$(IMAGES)/disk.img bs=40017920 conv=sync
# Add the file system
dd if=$(IMAGES)/filesys.img of=$(IMAGES)/disk.img bs=512 seek=2048 conv=notrunc
# Add the kernel
dd if=fuzix.romwbw of=$(IMAGES)/disk.img bs=512 seek=2 conv=notrunc
# Add the bootstrap
dd if=boot-romwbw.bin of=$(IMAGES)/disk.img bs=512 seek=2 conv=notrunc
# And kernel
dd if=../../fuzix.bin of=$(IMAGES)/disk.img bs=512 seek=4 conv=notrunc
# Make an emulator image of it
cat $(FUZIX_ROOT)/Standalone/filesystem-src/idehdr.40M $(IMAGES)/disk.img > $(IMAGES)/emu-ide.img
12 changes: 6 additions & 6 deletions Kernel/platform/platform-z80retro/boot-romwbw.S
Original file line number Diff line number Diff line change
Expand Up @@ -72,22 +72,22 @@ bootit:
ld e, 32 ; 32 sectors (16K)
push bc
rst 8 ; Can error but if so wtf do we do ?
ld hl,0x8000
ld hl,0x8100
ld de,0x0100
ld bc,0x4000 ; We've loaded 0100-40FF
ld bc,0x3F00 ; We've loaded 0100-4000
ldir
pop bc
ld hl,0x8000
ld e,32 ; Load the next 16K
ld e,32 ; Load the next 16K
push bc
rst 8
ld hl,0x8000 ; Move it into place
ld de,0x4100
ld de,0x4000
ld bc,0x4000
ldir
pop bc
ld hl,0x8100 ; Now load 8100 up
ld e, 55 ; takes us up to F100. If that's not enough
ld hl,0x8000 ; Now load 8000 up
ld e, 55 ; takes us up to F000. If that's not enough
; before unpack we have a problem as we
; will need to move the loader
rst 8
Expand Down
2 changes: 1 addition & 1 deletion Kernel/platform/platform-z80retro/crt0.S
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ init: ; must be at 0x0100 as we are loaded at that

ld sp, kstack_top
; Move the common memory where it belongs
ld hl, __data
ld hl, __bss
ld de, __common
ld bc, __common_size
ldir
Expand Down
20 changes: 19 additions & 1 deletion Kernel/platform/platform-z80retro/z80retro.S
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,10 @@ inchar_s:
.export _sd_spi_rx_sector

_sd_spi_tx_byte:
ld e,l
pop hl
pop de
push de
push hl
sd_tx:
; bit 0
rl e
Expand Down Expand Up @@ -506,9 +509,12 @@ sd_tx:
; Receive is by far the most important path
;
_sd_spi_rx_byte:
push bc
ld c,0xFF
call sd_rx
pop bc
ld l,e
ld h,0
ret

; FIXME - rotate C
Expand Down Expand Up @@ -572,6 +578,11 @@ sd_rx:
ret

_sd_spi_rx_sector:
pop de
pop hl
push hl
push de
push bc
ld bc,0xFF ; 0 for count 255 for reload of A
ld a,(_td_raw)
or a
Expand All @@ -591,9 +602,15 @@ rx_byte:
ld (hl),e
inc hl
djnz rx_byte
pop bc
jp map_kernel

_sd_spi_tx_sector:
pop de
pop hl
push hl
push de
push bc
ld b,0
ld a,(_td_raw)
or a
Expand All @@ -613,6 +630,7 @@ tx_byte:
inc hl
call sd_tx
djnz tx_byte
pop bc
jp map_kernel

;
Expand Down

0 comments on commit 9b17be6

Please sign in to comment.