CSRCS += devices.c main.c devinput.c
DISCARD_CSRCS = discard.c devhd_discard.c
-ASRCS = trs80.s trs80-bank94.s crt0.s
+ASRCS = trs80.s trs80-bank.s crt0.s
ASRCS += tricks.s commonmem.s floppy.s drivewire.s
DSRCS = ../dev/devdw.c
rm -f $(OBJS) $(JUNK) core *~
image: trs80load.bin
+ dd if=/dev/zero of=boot.raw bs=256 count=720
+ # Boot block at 0,0
+ dd if=trs80load.bin of=boot.raw bs=256 count=1 conv=notrunc
+ # Kernel lives on the end of the disk (so we can add an fs)
+ dd if=../fuzix.bin of=boot.raw bs=1 seek=133632 conv=notrunc
+ ../tools/makejv3 -s -t dd40s -d boot.raw boot4p.jv3
trs80load.bin: trs80load.s
sdasz80 -o trs80load.s
This port supports the following configurations currently
- TRS80 Model 4/4P (including gate array floppy disk workarounds)
+ TRS80 Model 4/4P (including gate array floppy disk workarounds) with
+ 128K of RAM fitted
Options:
Floppy Disk (somewhat basic support, no format tool yet)
Hard Disk (Tandy compatible)
Micro Labs Grafyx
Alpha Joystick
IDE adapter
+ Alpha Technologies SuperMem (on port 0x43)
+ Anitek HyperMem (on port 0x90)
Not Supported:
XLR8R - to do it well is a different port
tree.
Requirements:
- 128K RAM fitted
+ 128K or banked RAM fitted
Hard disk drive (will be used for swap), or a suitable memory
expander board could be used with a bit of tweaking (or both!)
(The hard disk code should work with the Lo-tech IDE adapter but
/* Full key up/down support */
#define CONFIG_INPUT_GRABMAX 3
-/* Support extra banked expansion memory using port 0x94 */
-#define CONFIG_MAP94
-#ifdef CONFIG_MAP94
#define MAX_MAPS 62
-#else
-#define MAX_MAPS 2
-#endif
#define MAP_SIZE 0x8000
{
}
-uint8_t nbanks = 2; /* Default 2 banks, unless port 94 probe updates */
+uint8_t nbanks = 2; /* Default 2 banks, unless we probe and find a
+ banked memory card */
void pagemap_init(void)
{
-#ifdef CONFIG_MAP94
int i = nbanks - 1;
while (i) {
pagemap_add(i); /* Mode 3, U64K low 32K mapped as low 32K */
pagemap_add(i|0x80); /* Mode 3, U64K high 32K mapped as low 32K */
i--;
}
-#else
- pagemap_add(0x63); /* Mode 3, U64K low 32K mapped as low 32K */
- pagemap_add(0x73); /* Mode 3, U64K high 32K mapped as low 32K */
-#endif
}
platform-trs80/crt0.rel
platform-trs80/commonmem.rel
platform-trs80/trs80.rel
-platform-trs80/trs80-bank94.rel
+platform-trs80/trs80-bank.rel
start.rel
version.rel
lowlevel-z80.rel
;
-; TRS 80 banking logic for the base Model 4 and 4P
+; TRS 80 banking logic for the base Model 4 and 4P with
+; the port 0x94 banking extensions.
;
.module trs80bank
.globl _modout
; imported symbols
- .globl _program_vectors
+ .globl _program_vectors
.globl _ramsize
.globl _procmem
+ .globl _nbanks
.globl s__COMMONMEM
.globl l__COMMONMEM
.area _CODE
init_hardware:
- in a,(0x94) ; Check for the Huffman banking
- cp #0xFF ; mod. If so set 0x94 bit 0 so
- jr z, bank_normal ; we run sanely
- set 0,a
- out (0x94),a
-bank_normal:
- ; set system RAM size
- ld hl, #128
+ call detect94
ld (_ramsize), hl
- ld hl, #(128-64) ; 64K for kernel
+ ld de, #64 ; for kernel
+ or a
+ sbc hl, de
ld (_procmem), hl
; set up interrupt vectors for the kernel (also sets up common memory in page 0x000F which is unused)
.area _COMMONMEM
-opsave: .db 0x06
+opsave: .db 0x06 ; used as a word so keep together
+save94: .db 0x01
_opreg: .db 0x06 ; kernel map, 80 columns
_modout: .db 0x50 ; 80 column, sound enabled, altchars off,
; external I/O enabled, 4MHz
+
+detect94:
+ in a,(0x94)
+ cp #0xFF
+ jr z, bank94_absent
+;
+; Seems we have banking extensions present
+;
+; Write 0xA5 into a fixed location in all banks but zero
+;
+; For each bank check the byte selected is A5 and write the bank into
+; it. When we see a bank not reporting A5 we have found the wrap.
+;
+ ld a, #0x63 ; map extended memory into low 32K
+ out (0x84),a
+ ld a, #0xA5
+ ld bc, #0x1f94
+ ld hl, #0x80 ; pick somewhere which won't hit us!
+markall:
+ out (c), b
+ ld (hl), a
+ djnz markall
+
+scanall: inc b
+ bit 5, b
+ jr nz, scandone
+ out (c), b
+ cp (hl) ; Still A5 ?
+ jr nz, scandone
+ ld (hl), b
+ jr scanall
+scandone:
+ ld a,(_opreg) ; restore mapping of kernel
+ out (0x84),a
+ ld a, b
+ ld (_nbanks), a
+ xor a
+ ; B is the first bank we don't have, 0 based, so B is number of
+ ; 64K banks we found (max 32)
+ srl b ; BA *= 64
+ rra
+ srl b
+ rr a
+ ld l, a ; Report size in HL
+ ld h, b
+ ret
+bank94_absent:
+ xor a
+ ld h, a
+ ld l, #128 ; We ought to check/abort on a 64K box ?
+ ret
;
; Mapping set up for the TRS80 4/4P
;
; The top 32K bank holds kernel code and pieces of common memory
-; The lower 32K is switched between the various user banks. On a
-; 4 or 4P without add in magic thats 0x62 and 0x63 mappings.
+; The lower 32K is switched between the various user banks and the
+; base kernel bank
;
map_kernel:
push af
and #0x8C ; keep video bits
or #0x02 ; map 2, base memory
ld (_opreg), a
- out (0x84), a
+ out (0x84), a ; base memory so 0x94 doesn't matter
pop af
ret
;
; Userspace mapping is mode 3, U64K/L32 mapped at L64K/L32
+; Mapping codes 0x63 / 0x73. 0x94 on a bank expanded TRS80 then
+; selects how the upper bank decodes
;
map_process:
ld a, h
map_process_hl:
ld a, (_opreg)
and #0x8C
- or (hl) ; udata page
+ or #0x63
+ bit 7, (hl) ; low or high ?
+ jr z, maplo
+ or #0x10
+maplo:
ld (_opreg), a
out (0x84), a
- ret
+ ld a, (hl)
+ and #0x1F
+ ret z ; not using bank94
+ out (0x94), a
+ ret
map_process_a: ; used by bankfork
push af
ld b, a
ld a, (_opreg)
and #0x8C
- or b
+ or #0x63
+ bit 7, b
+ jr z, maplo2
+ or #0x10
+maplo2:
ld (_opreg), a
out (0x84), a
+ ld a, b
+ and #0x1f
+ jr z, nobank94 ; zero means no bank94 hw present
+ out (0x94), a
+nobank94:
pop bc
pop af
ret
ld a, (_opreg)
and #0x73
ld (opsave), a
+ in a,(0x94)
+ ld (save94), a
pop af
ret
map_restore:
push af
push bc
- ld a, (opsave)
- ld b, a
+ ld bc, (opsave) ; c = opsave b = save94
ld a, (_opreg)
and #0x8C
- or b
+ or c
ld (_opreg), a
out (0x84), a
+ ld a, b
+ and #0x1f
+ jr z, norestore94
+ out (0x94), a
+norestore94:
pop bc
pop af
ret
-
+++ /dev/null
-;
-; TRS 80 banking logic for the base Model 4 and 4P with
-; the port 0x94 banking extensions.
-;
-
- .module trs80bank
-
- ; exported symbols
- .globl init_hardware
- .globl map_kernel
- .globl map_process
- .globl map_process_a
- .globl map_process_always
- .globl map_save
- .globl map_restore
- .globl _opreg
- .globl _modout
-
- ; imported symbols
- .globl _program_vectors
- .globl _ramsize
- .globl _procmem
- .globl _nbanks
-
- .globl s__COMMONMEM
- .globl l__COMMONMEM
-
- .include "kernel.def"
- .include "../kernel.def"
-
-; -----------------------------------------------------------------------------
-; KERNEL MEMORY BANK (below 0xE800, only accessible when the kernel is mapped)
-; -----------------------------------------------------------------------------
- .area _CODE
-
-init_hardware:
- call detect94
- ld (_ramsize), hl
- ld de, #64 ; for kernel
- or a
- sbc hl, de
- ld (_procmem), hl
-
- ; set up interrupt vectors for the kernel (also sets up common memory in page 0x000F which is unused)
- ld hl, #0
- push hl
- call _program_vectors
- pop hl
-
- im 1 ; set CPU interrupt mode
-
- ; interrupt mask
- ; 60Hz timer on
-
- ld a, #0x24 ; 0x20 for serial
- out (0xe0), a
- ret
-
-
-;------------------------------------------------------------------------------
-; COMMON MEMORY PROCEDURES FOLLOW
-
- .area _COMMONMEM
-
-opsave: .db 0x06 ; used as a word so keep together
-save94: .db 0x01
-_opreg: .db 0x06 ; kernel map, 80 columns
-_modout: .db 0x50 ; 80 column, sound enabled, altchars off,
- ; external I/O enabled, 4MHz
-
-detect94:
- in a,(0x94)
- cp #0xFF
- jr z, bank94_absent
-;
-; Seems we have banking extensions present
-;
-; Write 0xA5 into a fixed location in all banks but zero
-;
-; For each bank check the byte selected is A5 and write the bank into
-; it. When we see a bank not reporting A5 we have found the wrap.
-;
- ld a, #0x63 ; map extended memory into low 32K
- out (0x84),a
- ld a, #0xA5
- ld bc, #0x1f94
- ld hl, #0x80 ; pick somewhere which won't hit us!
-markall:
- out (c), b
- ld (hl), a
- djnz markall
-
-scanall: inc b
- bit 5, b
- jr nz, scandone
- out (c), b
- cp (hl) ; Still A5 ?
- jr nz, scandone
- ld (hl), b
- jr scanall
-scandone:
- ld a,(_opreg) ; restore mapping of kernel
- out (0x84),a
- ld a, b
- ld (_nbanks), a
- xor a
- ; B is the first bank we don't have, 0 based, so B is number of
- ; 64K banks we found (max 32)
- srl b ; BA *= 64
- rra
- srl b
- rr a
- ld l, a ; Report size in HL
- ld h, b
- ret
-bank94_absent:
- xor a
- ld h, a
- ld l, #128 ; We ought to check/abort on a 64K box ?
- ret
-;
-; Mapping set up for the TRS80 4/4P
-;
-; The top 32K bank holds kernel code and pieces of common memory
-; The lower 32K is switched between the various user banks and the
-; base kernel bank
-;
-map_kernel:
- push af
- ld a, (_opreg)
- and #0x8C ; keep video bits
- or #0x02 ; map 2, base memory
- ld (_opreg), a
- out (0x84), a ; base memory so 0x94 doesn't matter
- pop af
- ret
-;
-; Userspace mapping is mode 3, U64K/L32 mapped at L64K/L32
-; Mapping codes 0x63 / 0x73. 0x94 on a bank expanded TRS80 then
-; selects how the upper bank decodes
-;
-map_process:
- ld a, h
- or l
- jr z, map_kernel
-map_process_hl:
- ld a, (_opreg)
- and #0x8C
- or #0x63
- bit 7, (hl) ; low or high ?
- jr z, maplo
- or #0x10
-maplo:
- ld (_opreg), a
- out (0x84), a
- ld a, (hl)
- and #0x1F
- ret z ; not using bank94
- out (0x94), a
- ret
-
-map_process_a: ; used by bankfork
- push af
- push bc
- ld b, a
- ld a, (_opreg)
- and #0x8C
- or #0x63
- bit 7, b
- jr z, maplo2
- or #0x10
-maplo2:
- ld (_opreg), a
- out (0x84), a
- ld a, b
- and #0x1f
- jr z, nobank94 ; zero means no bank94 hw present
- out (0x94), a
-nobank94:
- pop bc
- pop af
- ret
-
-map_process_always:
- push af
- push hl
- ld hl, #U_DATA__U_PAGE
- call map_process_hl
- pop hl
- pop af
- ret
-
-map_save: push af
- ld a, (_opreg)
- and #0x73
- ld (opsave), a
- in a,(0x94)
- ld (save94), a
- pop af
- ret
-
-map_restore:
- push af
- push bc
- ld bc, (opsave) ; c = opsave b = save94
- ld a, (_opreg)
- and #0x8C
- or c
- ld (_opreg), a
- out (0x84), a
- ld a, b
- and #0x1f
- jr z, norestore94
- out (0x94), a
-norestore94:
- pop bc
- pop af
- ret
.ascii 'seek\0'
bad: jr bad
secmove: xor a
- dec a
ld (secnum), a
nextsec:
ld a, (secnum)
inc a
ld (secnum), a
- cp #18
+ cp #19 ; was 18
jr z, lastsec
push hl
call floppy_read