diff --git a/src/4cade.init.a b/src/4cade.init.a index 43aaa3622..260c763eb 100644 --- a/src/4cade.init.a +++ b/src/4cade.init.a @@ -363,6 +363,21 @@ CopyDevs !word gGamesListStore !word - +!ifndef RELEASE { + +READ_ROM_NO_WRITE + lda #40 + sta $21 + lda #36 + sta $24 + dec $25 + jsr $FC22 + lda SRC+1 + jsr $FDDA + lda SRC + jsr $FDDA + +READ_RAM2_WRITE_RAM2 +} + +LDADDR gGamesListStore jsr okvs_len sta GameCount diff --git a/src/constants.a b/src/constants.a index bad0ab756..a0928fdbd 100644 --- a/src/constants.a +++ b/src/constants.a @@ -9,7 +9,7 @@ ; D000..E891 - persistent data structures (per-game cheat categories, ; gGlobalPrefsStore, gGamesListStore) ; ...unused... -; E9E6..FFF9 - main program code +; EA6F..FFF9 - main program code ; FFFA..FFFF - NMI, reset, IRQ vectors ; ; LC RAM BANK 2 @@ -123,7 +123,7 @@ MOCKINGBOARD_SLOT = %00001111 HAS_SPEECH = %10000000 ; AND masks for game info bitfield (after game title in gGamesList) -HAS_DHGR_TITLE = %10000000 +HAS_DHGR_TITLE = %10000000 ; this one is hard-coded via BMI instead of AND/BNE CHEAT_CATEGORY = %00001111 ; AND masks for MachineStatus diff --git a/src/macros.a b/src/macros.a index 718781cbc..86c0c3e61 100755 --- a/src/macros.a +++ b/src/macros.a @@ -11,16 +11,12 @@ !macro PARAMS_ON_STACK .bytes { pla sta PARAM - pla - tax - stx PARAM+1 - lda #.bytes clc - adc PARAM + adc #.bytes tay - bcc + - inx -+ txa + pla + sta PARAM+1 + adc #0 pha tya pha diff --git a/src/okvs.a b/src/okvs.a index 8d6fa4fc5..229287485 100644 --- a/src/okvs.a +++ b/src/okvs.a @@ -1,5 +1,5 @@ ;license:MIT -;(c) 2018-9 by 4am +;(c) 2018-2020 by 4am ; ; Ordered key/value store (6502 compatible) ; @@ -127,7 +127,7 @@ okvs_append ; PTR -> store ; Y = 0 lda (PTR),y ; A = number of keys in store - clc + ;;clc adc #1 pha ; will return this later sta (PTR),y ; increment number of keys @@ -155,7 +155,7 @@ okvs_append cpy #$FF bne - - sec + ;;sec txa adc PTR ; update PTR to byte after copied key sta PTR @@ -163,7 +163,7 @@ okvs_append inc PTR+1 + ; PTR -> space for new value +LDPARAMPTR 5, SRC ; SRC -> new value to copy - ldy #7 + iny ;;ldy #7 lda (PARAM),y ; get max length of value tax bne + @@ -260,8 +260,8 @@ KEYLEN = *+1 adc KEYLEN bcc + iny -+ clc - adc #2 + clc ++ adc #2 sta PTR bcc + iny diff --git a/src/ui.animation.a b/src/ui.animation.a index 45efc7223..2cebe854a 100644 --- a/src/ui.animation.a +++ b/src/ui.animation.a @@ -1,5 +1,5 @@ ;License:MIT -;(c) 2018-9 by 4am +;(c) 2018-2020 by 4am ; ; functions for animated title screens ; @@ -28,9 +28,9 @@ MaybeAnimateTitle eor #$60 + sta SAVE+1 and #$60 - sta @a+2 + sta PageFrom+2 eor #$60 - sta @b+2 + tax lda #$FD sta SAVE ldy #0 @@ -41,17 +41,8 @@ MaybeAnimateTitle ; file -- this area part of a 'screen ; hole' and is not displayed on screen) bne @exit ; if not, we're done here - - ; copy one HGR screen to the other - ldx #$20 -@a lda $FD00,y ; SMC -@b sta $FD00,y ; SMC - iny - bne @a - inc @a+2 - inc @b+2 - dex - bne @a + txa + jsr CopyHGR ; load the animation routine, which is stored in a subdirectory by filename jsr GetGameToLaunch diff --git a/src/ui.attract.dhgr.a b/src/ui.attract.dhgr.a index e92b14e90..b2d31f32c 100644 --- a/src/ui.attract.dhgr.a +++ b/src/ui.attract.dhgr.a @@ -318,32 +318,13 @@ RedrawForDHGR ; $0200..$02CB clobbered by decompressor ;------------------------------------------------------------------------------ DecompressDHGR - jsr SwitchToBank2 - jsr EnableAccelerator - clc - lda sizelo2 - adc #$F8 - sta _byte_lo - lda sizehi2 - adc #$3F - sta _byte_hi sta $C003 sta $C005 - jsr decrunch + jsr DecompressHGR sta $C004 lda #$60 - sta @copyaux+2 + sta PageFrom+2 lda #$40 - sta @copyaux+5 - ldy #0 -@copyaux - lda $D100, y ; SMC - sta $D100, y ; SMC - iny - bne @copyaux - inc @copyaux+5 - inc @copyaux+2 - bpl @copyaux + jsr CopyHGR sta $C002 - jsr DisableAccelerator - jmp SwitchToBank1 + rts diff --git a/src/ui.attract.gr.a b/src/ui.attract.gr.a index e984babc6..9c1bb5901 100644 --- a/src/ui.attract.gr.a +++ b/src/ui.attract.gr.a @@ -1,5 +1,5 @@ ;license:MIT -;(c) 2018-9 by 4am +;(c) 2018-2020 by 4am ; ; GR action slideshows ; @@ -52,16 +52,12 @@ GRSingle ; graphics mode set to display lo-res screen ;------------------------------------------------------------------------------ BlankGR + ldy #$2C ; BIT + sty PageFrom ldx #$04 - stx @loop+2 + stx PageTo+2 lda #0 - tay -@loop sta $FD00,y - iny - bne @loop - inc @loop+2 - dex - bne @loop + jsr ClearGR bit PAGE1 bit $C056 ; set GR mode jmp GRMode diff --git a/src/ui.attract.hgr.a b/src/ui.attract.hgr.a index cdb139e9a..022c55d1f 100644 --- a/src/ui.attract.hgr.a +++ b/src/ui.attract.hgr.a @@ -173,15 +173,18 @@ HGRActionCallback ; $0200..$02CB clobbered by decompressor ;------------------------------------------------------------------------------ DecompressHGR + lda #$3F + +DecompressCommon + pha jsr SwitchToBank2 jsr EnableAccelerator clc lda sizelo2 adc #$F8 sta _byte_lo - lda sizehi2 - adc #$3F + pla + adc sizehi2 sta _byte_hi jsr decrunch - jsr DisableAccelerator - jmp SwitchToBank1 + jmp DisableAcceleratorAndSwitchToBank1 diff --git a/src/ui.attract.shr.a b/src/ui.attract.shr.a index 40205356a..fe6fe2fe7 100644 --- a/src/ui.attract.shr.a +++ b/src/ui.attract.shr.a @@ -121,13 +121,13 @@ BlankSHR jsr Home lda NEWVIDEO ; set GS NEWVIDEO mode to turn on linearize - ora #%01000000 + ora #%01000000 ; can't use TSB here - might not be 65816 sta NEWVIDEO sta WRITEAUXMEM ; writes go to auxmem lda SHADOW ; enable auxmem-to-bank-E1 shadowing on IIgs - and #$F7 + and #$F7 ; can't use TRB here - might not be 65816 sta SHADOW lda #$20 ; clear $2000..$9FFF in auxmem @@ -137,7 +137,7 @@ BlankSHR sta WRITEMAINMEM ; writes go to main memory lda NEWVIDEO ; set GS NEWVIDEO mode to turn on SHR mode - ora #%10000001 + ora #%10000001 ; can't use TSB here - might not be 65816 sta NEWVIDEO rts @@ -154,15 +154,6 @@ BlankSHR ; $0200..$02CB clobbered by decompressor ;------------------------------------------------------------------------------ DecompressSHR - jsr SwitchToBank2 - jsr EnableAccelerator - clc - lda sizelo2 - adc #$F8 - sta _byte_lo - lda sizehi2 - adc #$1F - sta _byte_hi - jsr decrunch - jsr DisableAccelerator - jmp SwitchToBank1 + lda #$1F + jmp DecompressCommon + diff --git a/src/ui.credits.a b/src/ui.credits.a index a6f03e49e..33f20ee85 100644 --- a/src/ui.credits.a +++ b/src/ui.credits.a @@ -1,5 +1,5 @@ ;license:MIT -;(c) 2018-9 by 4am +;(c) 2018-2020 by 4am ; ; credits page ; @@ -26,7 +26,7 @@ Credits lda OffscreenPage ror ; draw on offscreen page +LDADDR $8000 - ldx #0 + tax jsr DrawPage ; draw credits jsr ShowOtherPage ; show credits jsr WaitForKeyFor30Seconds; wait diff --git a/src/ui.font.a b/src/ui.font.a index 0c1b77201..e11331067 100644 --- a/src/ui.font.a +++ b/src/ui.font.a @@ -1,5 +1,5 @@ ;license:MIT -;(c) 2018-9 by 4am +;(c) 2018-2020 by 4am ; ; hi-res font drawing routines ; @@ -18,24 +18,26 @@ DrawString jsr SwitchToBank2 jsr DrawStringInternal - jmp SwitchToBank1 + bmi JmpSwitch ; always DrawPage jsr SwitchToBank2 jsr DrawPageInternal + +JmpSwitch jmp SwitchToBank1 Draw40Chars jsr SwitchToBank2 jsr Draw40CharsInternal - jmp SwitchToBank1 + beq JmpSwitch ; always DrawCenteredString jsr SwitchToBank2 jsr DrawCenteredStringInternal - jmp SwitchToBank1 + bmi JmpSwitch ; always DrawBuffer jsr SwitchToBank2 jsr DrawBufferInternal - jmp SwitchToBank1 + bmi JmpSwitch ; always diff --git a/src/ui.offscreen.a b/src/ui.offscreen.a index 710c3b474..01a05b805 100644 --- a/src/ui.offscreen.a +++ b/src/ui.offscreen.a @@ -1,5 +1,5 @@ ;License:MIT -;(c) 2018-9 by 4am +;(c) 2018-2020 by 4am ; ; functions for managing which HGR page is showing, and doing things on the other one ; @@ -94,8 +94,8 @@ LoadGameTitleOffscreen sta SAVE tay lda (PTR),y ; A = game info bitfield - and #HAS_DHGR_TITLE - bne @dhgr + ;;and #HAS_DHGR_TITLE + bmi @dhgr @hgr jsr ForceHGRMode jsr GetOffscreenAddress @@ -135,17 +135,35 @@ ClearHGR1 lda #$20 ; note to self: LDX #$20 can't move here ldx #$20 ClearMem - sta @a+2 + ldy #$2C ; BIT + bne + ; always + +;------------------------------------------------------------------------------ +; CopyHGR +; +; in: source and destination page pointers set +; out: all registers clobbered +; 8kb memory region duplicated +;------------------------------------------------------------------------------ +CopyHGR + ldx #$20 + ldy #$B9 ; LDY ++ sty PageFrom + sta PageTo+2 lda #$80 +ClearGR ldy #0 -@a sta $2000,y +PageFrom lda $FD00,y ; SMC +PageTo sta $FD00,y ; SMC iny - bne @a - inc @a+2 + bne PageFrom + inc PageFrom+2 + inc PageTo+2 dex - bne @a + bne PageFrom rts + ResyncPage jsr ToggleOffscreenPage ; /!\ execution falls through here to ShowOtherPage