fix timing, free some memory

This commit is contained in:
Peter Ferrie 2019-04-16 22:56:58 -07:00
parent 22b2c8a867
commit c309ea313e
3 changed files with 77 additions and 114 deletions

View File

@ -48,7 +48,7 @@ flag = $FF ; byte
RELBASE = $2000 ; dummy assignment for first build RELBASE = $2000 ; dummy assignment for first build
; to allow calculation of proper value ; to allow calculation of proper value
} }
LOWPOINT = $4300 ; lowest available address for code LOWPOINT = $4000 ; lowest available address for code
HIGHPOINT = $B200 ; highest available address+1 for code HIGHPOINT = $B200 ; highest available address+1 for code
BASEPAGE = $10 ; Special Delivery tracer assumes BASEPAGE = $10 ; Special Delivery tracer assumes
; this is $10, so don't change it! ; this is $10, so don't change it!

View File

@ -7,12 +7,12 @@
; 0A00..0AFF - backup of zero page during Special Delivery tracer, used by RAM disk ; 0A00..0AFF - backup of zero page during Special Delivery tracer, used by RAM disk
; 0B00..0BFF - used by RAM disk ; 0B00..0BFF - used by RAM disk
; 0C00..0CFF - clobbered by Special Delivery tracer ; 0C00..0CFF - clobbered by Special Delivery tracer
; 0D00..0FFF - unused ; 0D00..0EFF - unused
; 0F00..0FFF - backup of page $BF (SaveProDOS, SwapProDOS)
; 1000..1FFF - data buffer for current track ; 1000..1FFF - data buffer for current track
; 2000..35FF - clobbered by Special Delivery tracer ; 2000..35FF - clobbered by Special Delivery tracer
; 3600..3FFF - clobbered by lomem DOS 3.3 / Special Delivery tracers ; 3600..3FFF - clobbered by lomem DOS 3.3 / Special Delivery tracers
; 4000..42FF - backup of zero page, page 3, page $BF (SaveProDOS, SwapProDOS) ; 4000..B1FF - program code
; 4300..B1FF - program code
; B200..BFFF - clobbered by DOS boot tracer (RDOS is B200+, DOS 3.x is B600+) ; B200..BFFF - clobbered by DOS boot tracer (RDOS is B200+, DOS 3.x is B600+)
;------------------------------- ;-------------------------------
@ -20,23 +20,15 @@
;------------------------------- ;-------------------------------
; SaveProDOS ; SaveProDOS
; saves memory pages used by ProDOS ; saves memory pages used by ProDOS
; pages $00, $03, $BF ; pages $BF
; in: none ; in: none
; out: all flags and registers clobbered ; out: all flags and registers clobbered
;------------------------------- ;-------------------------------
!zone { !zone {
SaveProDOS SaveProDOS
lda #$00
ldx #$40
ldy #$01
jsr CopyMemory
lda #$03
ldx #$41
ldy #$01
jsr CopyMemory
SaveGlobal SaveGlobal
lda #$BF lda #$BF
ldx #$42 ldx #$0F
ldy #$01 ldy #$01
;;jsr CopyMemory ; fall through ;;jsr CopyMemory ; fall through
} }
@ -118,23 +110,13 @@ ReorderBuffer
;------------------------------- ;-------------------------------
; SwapProDOS ; SwapProDOS
; saves/restores memory pages used by ProDOS ; saves/restores memory pages used by ProDOS
; pages $00, $03, $BF ; pages $BF
; in: none ; in: none
; out: all flags and registers clobbered ; out: all flags and registers clobbered
;------------------------------- ;-------------------------------
SwapProDOS SwapProDOS
lda #$00
ldx #$40
ldy #$01
sec
jsr SwapMemory
lda #$03
ldx #$41
ldy #$01
sec
jsr SwapMemory
lda #$BF lda #$BF
ldx #$42 ldx #$0F
ldy #$01 ldy #$01
sec sec
;;jsr SwapMemory ; fall through ;;jsr SwapMemory ; fall through

View File

@ -12,7 +12,8 @@ Choplifter
bit gMode ; nothing to do here in verify-only mode bit gMode ; nothing to do here in verify-only mode
bpl .exit bpl .exit
;;prepare write routine at $2000-21ff first ;; prepare write routine at $2000 for relocated address at $207
;; the difficulty here is to find three spare pages across all games
lda #$00 lda #$00
sta gCommand sta gCommand
@ -21,11 +22,6 @@ Choplifter
jsr IncProgress jsr IncProgress
.read .read
lda KEY
bpl .continue
jmp .cancel
.continue
asl gTrack asl gTrack
jsr ReadChoplifter jsr ReadChoplifter
lsr gTrack lsr gTrack
@ -98,10 +94,6 @@ Choplifter
jsr .cleanup jsr .cleanup
jmp Pass jmp Pass
.cancel
jsr .cleanup
jmp Cancel
.cleanup .cleanup
lda $C0E8 lda $C0E8
lda #$01 lda #$01
@ -140,20 +132,16 @@ ReadChoplifter
.checkkey1 .checkkey1
lda KEY lda KEY
.linkcancel1
bmi .cancel bmi .cancel
jsr .readnib jsr .readnib
- cmp #$DD - cmp #$DD
bne .checkkey1 bne .checkkey1
jsr .readnib jsr .readnib
-- cmp #$F5 cmp #$F5
bne - bne -
jsr .readnib jsr .readnib
cmp #$D5 cmp #$D5
bne -- ; this is the same bug bne - ; this had the same bug (see below)
nop ; timing bits
nop ; timing bits
nop ; timing bits
ldx #$03 ldx #$03
- jsr .read4x4 - jsr .read4x4
jsr .read4x4 jsr .read4x4
@ -168,6 +156,10 @@ ReadChoplifter
bcs .checktrack20 bcs .checktrack20
rts rts
.cancel
jsr .cleanup
jmp Cancel
.settrack00 .settrack00
lda #$D5 lda #$D5
sta cmp1+1 sta cmp1+1
@ -190,21 +182,19 @@ ReadChoplifter
.checkkey0 .checkkey0
lda KEY lda KEY
.linkcancel2 .linkcancel2
bmi .linkcancel1 bmi .cancel
jsr .readnib jsr .readnib
- cmp cmp2+1 - cmp cmp2+1
bne .checkkey0 bne .checkkey0
jsr .readnib jsr .readnib
-- cmp cmp2+0 cmp cmp2+0
bne - bne -
jsr .readnib jsr .readnib
cmp cmp1+1 eor cmp1+1
bne -- ; this is a bug bne - ; this had a bug
; it allows PR0 PR1 [any] PR1 PR2 instead of requiring PR0 PR1 PR2 ; it branched to the middle nibble instead of the first one
nop ; timing bits ; it allowed PR0 PR1 [any] PR1 PR2 instead of requiring PR0 PR1 PR2
nop ; timing bits tay
nop ; timing bits
ldy #0
-- jsr .read4x4 -- jsr .read4x4
sta (modsrc), y sta (modsrc), y
iny iny
@ -246,81 +236,75 @@ ReadChoplifter
sta .prolog2+1 sta .prolog2+1
lda (BASEPAGE<<8)+$D3 lda (BASEPAGE<<8)+$D3
sta .prolog3+1 sta .prolog3+1
-- jsr .readnib
.checkkey2
lda KEY
.linkcancel3
bmi .linkcancel2
jsr .readnib
.prolog1 .prolog1
- cmp #$D1 ; SMC - cmp #$D1 ; SMC
bne .checkkey2 bne --
jsr .readnib jsr .readnib
.prolog2 .prolog2
-- cmp #$D1 ; SMC cmp #$D1 ; SMC
bne - bne -
jsr .readnib jsr .readnib
.prolog3 .prolog3
cmp #$D1 ; SMC eor #$D1 ; SMC
bne -- ; this is the same bug bne - ; this had the same bug
nop ; timing bits tax
nop ; timing bits -- lda $C0EC ; timing issue requires unrolling part of this
nop ; timing bits bpl --
ldx #$00 sec
- jsr .read4x4 rol
sta tmp
jsr .readnib
and tmp
sta (BASEPAGE+$0f)<<8,x sta (BASEPAGE+$0f)<<8,x
inx inx
jsr .read4x4 jsr .read4x4
sta (BASEPAGE+$0f)<<8,x sta (BASEPAGE+$0f)<<8,x
inx inx
jsr .read4x4 jsr .readnib
sec
rol
sta tmp
- lda $C0EC
bpl -
and tmp
sta (BASEPAGE+$0f)<<8,x sta (BASEPAGE+$0f)<<8,x
inx inx
cmp #$EA cmp #$EA
bne - bne --
ldx #0 ;; future work, just disable for now
.copywrite1 ;; ldx #0
lda $2000,x ;;.copywrite
sta (BASEPAGE+8)<<8,x ;; lda .writeroutine,x
inx ;; sta (BASEPAGE+8)<<8,x
bne .copywrite1 ;; inx
;; bne .copywrite
lda #$60 ; rts
sta ((BASEPAGE+8)<<8)+7
rts rts
.readtrack22 .readtrack22
ldx #$40 ldx #$40
ldy #0 ldy #0
-- dey
.checkkey3
dey
bne + bne +
dex dex
beq .copywrite2 beq ++
+ lda KEY + jsr .readnib
bmi .linkcancel3
jsr .readnib
- cmp #$D5 - cmp #$D5
bne .checkkey3 bne --
jsr .readnib jsr .readnib
-- cmp #$FF cmp #$FF
bne - bne -
jsr .readnib jsr .readnib
cmp #$DD cmp #$DD
bne -- ; this is the same bug bne - ; this had the same bug
nop ; timing bits
nop ; timing bits
nop ; timing bits
ldx #$00 ldx #$00
- jsr .read4x4 - jsr .read4x4
sta BASEPAGE<<8,x sta BASEPAGE<<8,x
inx inx
bne - bne -
++ rts
.copywrite2
lda $2100,x
sta (BASEPAGE+7)<<8,x
inx
bne .copywrite2
rts
.read4x4 .read4x4
- lda $C0EC - lda $C0EC
@ -359,7 +343,7 @@ ReadChoplifter
txa txa
sta (modsrc),y sta (modsrc),y
tya tya
adc #$17 ; carry set by sbc adc #$18-1 ; carry set by sbc
tay tay
txa txa
adc #$0F adc #$0F
@ -382,14 +366,15 @@ ReadChoplifter
jmp $4000 jmp $4000
.resume .resume
ldy #0 ldx #0
- lda .stager,y - lda .stager,x
sta $500,y sta $500,x
lda (*+$ff) and $ff00,y lda (*+$ff) and $ff00,x
sta $200,y sta $200,x
lda (*+$1ff) and $ff00,y lda (*+$1ff) and $ff00,x
sta $400,y sta $400,x
iny txs
inx
bne - bne -
jsr .dostep4 jsr .dostep4
ldy #2 ; pagehi, first table ldy #2 ; pagehi, first table
@ -408,10 +393,10 @@ ReadChoplifter
sta $801 sta $801
lda #2 lda #2
sta $27 sta $27
jsr $823 ; read half of write routine to $200 (but starts at $207) jsr $823 ; read write routine to $200 (but starts at $207)
inc $27 inc $27
jsr $823 ; read patch table to $400 jsr $823 ; read patch table to $400
ldy #0 ; avoid CFFA bug ldy #0 ; avoid CFFA bug (Y is not zero on return)
- lda $400,y - lda $400,y
sta .patcher+1 sta .patcher+1
lda $401,y lda $401,y
@ -428,14 +413,10 @@ ReadChoplifter
jsr .dostep2 ; reach track $22 jsr .dostep2 ; reach track $22
sta $3d sta $3d
dec $27 dec $27
jsr $823 ; read high scores jsr $823 ; read high scores to $400
inc $27 ldy #0 ; avoid CFFA bug (Y is not zero on return)
jsr $823 ; read half of write routine to $600 - lda $700,y
ldy #0 ; avoid CFFA bug
- lda ($26),y
sta $800,y sta $800,y
lda $600,y
sta $300,y
iny iny
bne - bne -
lda $C088,x lda $C088,x
@ -457,6 +438,6 @@ ReadChoplifter
jsr $82F jsr $82F
lsr $40 lsr $40
rts rts
} } ;$5xx
} } ;$Bxxx
} }