Skip to content

Commit

Permalink
Merge pull request #8 from ki3v/model2
Browse files Browse the repository at this point in the history
Model2
  • Loading branch information
ki3v authored Aug 30, 2022
2 parents dbd934a + 557bd03 commit cb8e5b2
Show file tree
Hide file tree
Showing 22 changed files with 1,370 additions and 302 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@
Icon*
*.bds
*.lst
trs80-*.gif
profile-*.gif
24 changes: 16 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
# This Makefile requires GNU Make or equivalent.
include os.mk

TARGET = trs80m13diag
TARGET = trs80m2diag trs80m13diag
ASMFILES = $(TARGET:%=%.asm)
CIMFILES = $(TARGET:%=%.cim)
BDSFILES = $(TARGET:%=%.bds)
BINFILES = $(TARGET:%=%.bin)
HEXFILES = $(TARGET:%=%.hex)

all: $(BINFILES)
trs80m13diag.bin: inc/z80.mac inc/spt.mac inc/spt.asm inc/memtestmarch.asm inc/trs80con.asm inc/trs80music.asm Makefile os.mk
trs80m13diag.bin: inc/z80.mac inc/spt.mac inc/spt.asm inc/memtestmarch.asm inc/trs80m13con.asm inc/trs80music.asm Makefile os.mk
trs80m2diag.bin: inc/z80.mac inc/spt.mac inc/spt.asm inc/memtestmarch.asm inc/trs80m2con.asm Makefile os.mk

.PHONY: clean realclean
clean:
Expand All @@ -34,23 +35,30 @@ $(BDSFILES): %.bds: %.bin


.PHONY: emu
# emu: $(TARGET:%=%.emu)

MODEL = -m3
MEM = 32
SIMFLAGS = $(MODEL) -mem $(MEM)
# MEM = 32
EMUFLAGS = $(MODEL) $(foreach m,$(MEM),-mem $(m))

emu: trs80m13diag.emu
emu1 emu1l emu3: emu
emu emu1 emu1l emu3 emu4: trs80m13diag.emu
emu2 emu12 emu16 emu6k: trs80m2diag.emu

emu1: MODEL = -m1 -nlc -nld
emu1l: MODEL = -m1
emu3: MODEL = -m3
emu2: MODEL = -m2
emu12: MODEL = -m12
emu16: MODEL = -m16
emu6k: MODEL = -m6000
emu4: MODEL = -m4
emu4p: MODEL = -m4p
emu4d: MODEL = -m4d


BREAKFLAGS=$(foreach brk,$(B),-b $(brk))

%.emu: %.bds %.bin
$(EMU) -vol 20 -rand $(SIMFLAGS) $(BREAKFLAGS) -rom $(abspath $*.bin) -ls $(abspath $*.bds)
$(EMU) -ee -vol 20 -rand $(EMUFLAGS) $(BREAKFLAGS) -rom $*.bin -ls $*.bds $(E)

.DEFAULT: all
.PHONY: all
121 changes: 85 additions & 36 deletions README.md

Large diffs are not rendered by default.

Binary file added documentation/M1_4k_animated.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added documentation/M2_128k_animated.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added documentation/M3_48k_animated.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed documentation/Normal Operation 16K Model 3.jpg
Binary file not shown.
Binary file removed documentation/Normal Operation 4K Model 3.png
Binary file not shown.
21 changes: 11 additions & 10 deletions inc/memtestmarch.asm
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
; This function must be RELOCATABLE (only relative jumps), and use NO RAM or STACK.
; These restrictions lead to somewhat long-winded, repetative code.

;; March C algorithm:
;; 1: write each location bottom to top with test value
;; 2: read each location bottom to top, compare to test value, then write complement
;; 3: read each location bottom to top, compare to complement, then write test value
;; 4: read each location top to bottom, compare to test value, then write complement
;; 5: read each location top to bottom, compare to complement, then write test value
;; 6: read each location top to bottom, compare to test value
;; March C- algorithm:
;; 1: (up w0) write each location bottom to top with test value
;; 2: (up r0,w1) read each location bottom to top, compare to test value, then write complement
;; 3: (up r1,w0) read each location bottom to top, compare to complement, then write test value
;; 4: (dn r0,w1) read each location top to bottom, compare to test value, then write complement
;; 5: (dn r1,w0) read each location top to bottom, compare to complement, then write test value
;; 6: (dn r0) read each location top to bottom, compare to test value

; Arguments:
; hl = current memory position under test
Expand Down Expand Up @@ -49,7 +49,7 @@ memtestmarch:
xor d ; calculate errored bits
or e
ld e,a ; save error bits to e
cp $ff ; if we have already found all bits bad
cp $FF ; if we have already found all bits bad
jr z,mtm_done_bounce ; then quit
ld a,d ; reload a with correct value
mtm2cont:
Expand All @@ -73,12 +73,12 @@ memtestmarch:
xor d ; calculate errored bits
or e
ld e,a ; save error bits to e
cp $ff ; if we have already found all bits bad
cp $FF ; if we have already found all bits bad
jr z,mtm_done_bounce ; then quit
ld a,d ; reload a with correct value
mtm3cont:
ld (hl),d ; fill with test value
ld a,$FF ; keep going so long as bc doesn't become -1 ($FFFF)
; ld a,$FF ; keep going so long as bc doesn't become -1 ($FFFF)
inc hl
dec bc
xor a ; keep going so long as bc doesn't become -1 ($FFFF)
Expand Down Expand Up @@ -180,4 +180,5 @@ memtestmarch:
scf
ret

memtestmarch_end equ $
;-----------------------------------------------------------------------------
48 changes: 36 additions & 12 deletions inc/spt.asm
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
; spt_ld_bc: pop bc
; ret
; code: lang=asm-collection tabSize=8
spt_ld_bc: pop bc
ret

; spt_ld_hl: pop hl
; ret

spt_ld_iy: pop iy
spt_select_test:
pop iy
ret

; spt_ld_bchl: pop bc
Expand All @@ -15,11 +17,8 @@ spt_ld_iy: pop iy
; ret


; spt_exit: ld sp,iy ; resume from the thread location saved in iy
; ret

spt_exit:
spthread_restore
SPTHREAD_RESTORE
ret


Expand All @@ -32,11 +31,36 @@ spt_jp_nc: pop hl
ld sp,hl
ret

spt_jp_z: pop hl
ret nz
spt_jp_c: pop hl
ret nc
ld sp,hl
ret

; do_spt_call_hl:
; spthread_restore
; jp (hl)
; spt_jp_z: pop hl
; ret nz
; ld sp,hl
; ret



; ; attempt to create subroutine to replace SPTHREAD_ENTER macro
; ; the downside of these is that they destroy HL, which is a hard pill to swallow in
; ; ramless code
; ; notes:
; ; if a subroutine immediately JP's here, we know that:
; ; (sp-2) contains the address of the routine that called us (because we got there by RET)
; ; (sp-2)+3 contains the address we can jp back to in order to continue
; spt_enter:
; dec sp
; dec sp
; pop hl
; SPTHREAD_ENTER
; jp (hl)


; ; call an all-threaded subroutine
; ; the parameter (pointed by SP) is where we are jumping
; spt_call:
; pop hl
; SPTHREAD_SAVE
; jp (hl)
49 changes: 27 additions & 22 deletions inc/spt.mac
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
; code: lang=asm-collection tabSize=8
; macros for placing interrupt vectors in the middle of a block of threaded code
spt_skip_intvec .macro
SPT_SKIP_INTVEC .macro
dw spt_jp, .intvec_continue ; continue after the NMI vector
place_intvec
PLACE_INTVEC
ld sp,0
reti
.intvec_continue:
.endm

spt_skip_nmivec .macro
SPT_SKIP_NMIVEC .macro
dw spt_jp, .nmivec_continue ; continue after the NMI vector
place_nmivec
PLACE_NMIVEC
ld sp,0 ; on model 1, NMI is connected to reset button
retn
.nmivec_continue:
Expand All @@ -18,17 +19,17 @@ spt_skip_nmivec .macro
; Start a threaded-code section by pointing to it with SP and issuing RET
; immediately following this macro should be the addresses (and optionally,
; parameters) for the threaded code
spthread_begin .macro
SPTHREAD_BEGIN .macro
.local threadstart
ld sp,.`threadstart
ld sp,.`threadstart
ret
.`threadstart:
.endm

; At the end of the threaded code section, place an address just beyond
; the list of addresses, to jump back to conventional code
spthread_end .macro
dw $+2
SPTHREAD_END .macro
dw $+2
.endm

; Save the stack pointer into the stack registers. This is analogous
Expand All @@ -38,37 +39,41 @@ spthread_end .macro
; innermost threaded stack frame can call a third-level machine-code
; subroutine, but that subroutine can't make any further calls or run
; threaded code itself.
spthread_save .macro
SPTHREAD_SAVE .macro
exx
ld d,h
ld e,l
ex de,hl
ld hl,0 ; copy old sp to iy
add hl,sp
exx
.endm

; The opposite of spthread_save. Pops SP off the simulated stack in
; The opposite of SPTHREAD_SAVE. Pops SP off the simulated stack in
; preparation for returning to the enclosing threaded stack frame.
spthread_restore .macro
SPTHREAD_RESTORE .macro
exx
ld sp,hl ; resume from the thread location saved in hl'
ld h,d
ld l,e
ex de,hl
exx
.endm

; The prologue for a subroutine that contains threaded code.
spthread_enter .macro
spthread_save
spthread_begin
SPTHREAD_ENTER .macro
SPTHREAD_SAVE
SPTHREAD_BEGIN
.endm

; The epilogue for a subroutine that contains threaded code. To be followed by RET
spthread_leave .macro
spthread_end
spthread_restore
SPTHREAD_LEAVE .macro
SPTHREAD_END
SPTHREAD_RESTORE
.endm

spt_con_offset .macro row,col


MAC_SPT_CON_GOTO .macro row,col
dw spt_con_goto, VBASE+(row*VLINE)+col
.endm

MAC_SPT_CON_OFFSET .macro row,col
dw VBASE+(row*VLINE)+col
.endm
11 changes: 3 additions & 8 deletions inc/trs80con.asm → inc/trs80m13con.asm
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,14 @@ con_home: ld ix,VBASE
spt_con_goto: pop ix
ret

mac_con_NL .macro
.local skip
con_NL:
ld a,ixl ; go to beginning of line
and $c0 ; then go to the next line
add a,$40
ld ixl,a ; store the low byte back
jr nc,.`skip
jr nc,.skip
inc ixh ; fix up high byte if there was a carry
.`skip:
.endm

con_NL:
mac_con_NL
.skip:
ret

con_clear:
Expand Down
Loading

0 comments on commit cb8e5b2

Please sign in to comment.