Add config menu

This commit is contained in:
Lucas Scharenbroich 2023-07-19 08:50:21 -05:00
parent 9cc5b2e3af
commit 268bed61d8
3 changed files with 480 additions and 269 deletions

View File

@ -38,10 +38,14 @@ CurrNTQueueEnd equ 40
BGToggle equ 44 BGToggle equ 44
LastEnable equ 46 LastEnable equ 46
ShowFPS equ 48 ShowFPS equ 48
HideStatusBar equ 50 ;HideStatusBar equ 50
;ROMPlayerY equ 52 ;ROMPlayerY equ 52
YOrigin equ 54 YOrigin equ 54
VideoMode equ 56 ; Configuration parameters
AudioMode equ 58
LastStatusUdt equ 60 ; For good/better video modes
OldOneSec equ 100 OldOneSec equ 100
RenderFlags equ 102 RenderFlags equ 102
NesTop equ 104 ; Clip any sprite that has a NES OAM y-coordinate above this line NesTop equ 104 ; Clip any sprite that has a NES OAM y-coordinate above this line
@ -54,11 +58,6 @@ ScreenTop equ 114 ; SCB line of the top of the play field
MinYScroll equ 116 ; Smallest YOrigin value: 0 when showing stratus bar, 16 when hiding status bar MinYScroll equ 116 ; Smallest YOrigin value: 0 when showing stratus bar, 16 when hiding status bar
MaxYScroll equ 118 ; Largest YOrigin value for GTESetBG0Origin MaxYScroll equ 118 ; Largest YOrigin value for GTESetBG0Origin
;VirtTop equ 104 ; The top virtual line that is the top of the active play field (excludes status bar)
;VirtBottom equ 106 ; The bottom virtual line that is bottom of the active play field
;MaxNesY equ 108 ; This is the largest NES y coordinate that will display in the active play field
;MinNesY equ 110 ; This is the smallest NES y coordinate that will display in the active play field
Tmp0 equ 240 Tmp0 equ 240
Tmp1 equ 242 Tmp1 equ 242
Tmp2 equ 244 Tmp2 equ 244
@ -84,47 +83,18 @@ FTblTmp equ 228
stz OldROMScrollEdge stz OldROMScrollEdge
stz LastAreaType stz LastAreaType
stz ShowFPS stz ShowFPS
stz HideStatusBar
stz YOrigin stz YOrigin
stz VideoMode
stz AudioMode
lda #1 lda #1
sta BGToggle sta BGToggle
lda #$0008 lda #$0008
sta LastEnable sta LastEnable
lda #16 stz LastStatusUdt
; lda #32
sta NesTop
lda #16
sta MinYScroll
lda #1
sta HideStatusBar
lda #128
sta ScreenHeight
lsr
lsr
lsr
sta ScreenRows
lda #200
sec
sbc ScreenHeight
sta MaxYScroll
lda NesTop
clc
adc ScreenHeight
sec
sbc #8
inc
sta NesBottom
; lda #0
; sta ScreenTop
; The next two direct pages will be used by GTE, so get another 2 pages beyond that for the ROM. We get ; The next two direct pages will be used by GTE, so get another 2 pages beyond that for the ROM. We get
; 4K of DP/Stack space by default, so there is plenty to share ; 4K of DP/Stack space by default, so there is plenty to share
@ -138,13 +108,7 @@ FTblTmp equ 228
adc #$1FF ; Stack starts at the top of the page adc #$1FF ; Stack starts at the top of the page
sta ROMStk sta ROMStk
; Initialize the sound hardware for APU emulation
lda #2 ; 0 = 240Hz, 1 = 120Hz, 2 = 60Hz (external)
jsr APUStartUp
; Start up GTE to drive the graphics ; Start up GTE to drive the graphics
; brl :debug
lda #ENGINE_MODE_USER_TOOL ; Engine in Fast Mode as a User Tool lda #ENGINE_MODE_USER_TOOL ; Engine in Fast Mode as a User Tool
jsr GTEStartUp ; Load and install the GTE User Tool jsr GTEStartUp ; Load and install the GTE User Tool
@ -174,96 +138,13 @@ FTblTmp equ 228
_GTESetAddress _GTESetAddress
; Install a custom tile callback to draw tiles directly on the screen w/proper palettes ; Install a custom tile callback to draw tiles directly on the screen w/proper palettes
; pea userTileDirectCallback pea userTileDirectCallback
; pea #^NESDirectTileBlitter pea #^NESDirectTileBlitter
; pea #NESDirectTileBlitter pea #NESDirectTileBlitter
; _GTESetAddress _GTESetAddress
; Get the address of a low-level routine that can be used to draw a tile directly to the graphics screen
; pea rawDrawTile
; _GTEGetAddress
; lda 1,s
; sta drawTilePatch+1
; lda 2,s
; sta drawTilePatch+2
; pla
; plx
; Initialize the graphics screen playfield (256x160). The NES is 240 lines high, so 160
; is a reasonable compromise.
; pea #128
; pea #184
pea #128
pei ScreenHeight
; pea #80
; pea #144
_GTESetScreenMode
pha ; Allocate space for x, y, width, height
pha
pha
pha
_GTEGetScreenInfo
pla ; Discard x
pla
sta ScreenTop
asl
asl
asl
asl
asl
sta ScreenBase
asl
asl
clc
adc ScreenBase
clc
adc #$2000+x_offset
sta ScreenBase
pla ; Discard width and height
pla
ldx #Area1Palette
lda #TmpPalette
jsr NESColorToIIgs
pea $0000
pea #^TmpPalette
pea #TmpPalette
_GTESetPalette
; Convert the CHR ROM from the cart into GTE tiles ; Convert the CHR ROM from the cart into GTE tiles
:debug jsr LoadTilesFromROM
ldx #0
ldy #0
:tloop
phx
phy
lda #TileBuff
jsr ConvertROMTile2
lda 1,s
pha ; start
inc
pha ; finish
pea #^TileBuff ; pointer
pea #TileBuff
_GTELoadTileSet
ply
iny
pla
clc
adc #16 ; NES tiles are 16 bytes
tax
cpx #512*16
bcc :tloop
; Start the FPS counter ; Start the FPS counter
pha pha
@ -272,7 +153,18 @@ FTblTmp equ 228
sta OldOneSec sta OldOneSec
; Show the configuration screen ; Show the configuration screen
; jsr ShowConfig jsr ShowConfig
lda #0
jsr ClearScreen
jsr InitPlayfield
; Initialize the sound hardware for APU emulation
lda #4
sec
sbc AudioMode ; 0 = good, 2 = better, 4 = best
lsr
jsr APUStartUp ; 0 = 240Hz, 1 = 120Hz, 2 = 60Hz (external)
; Set an internal flag to tell the VBL interrupt handler that it is ; Set an internal flag to tell the VBL interrupt handler that it is
; ok to start invoking the game logic. The ROM code has to be run ; ok to start invoking the game logic. The ROM code has to be run
@ -293,10 +185,6 @@ FTblTmp equ 228
;OffScr_LevelNumber = $0763 ;OffScr_LevelNumber = $0763
EvtLoop EvtLoop
:spin lda nmiCount
beq :spin
stz nmiCount
; sep #$20 ; sep #$20
; lda #0 ; lda #0
; stal ROMBase+$075f ; stal ROMBase+$075f
@ -330,7 +218,6 @@ EvtLoop
lda ShowFPS lda ShowFPS
beq :no_fps beq :no_fps
inc frameCount
pha pha
_GTEGetSeconds _GTEGetSeconds
pla pla
@ -341,7 +228,7 @@ EvtLoop
ldx #0 ldx #0
ldy #$FFFF ldy #$FFFF
lda frameCount lda frameCount
jsr DrawByte jsr DrawByte
lda frameCount lda frameCount
stz frameCount stz frameCount
@ -495,7 +382,7 @@ TmpPalette ds 32
lastKey dw 0 lastKey dw 0
singleStepMode dw 0 singleStepMode dw 0
nmiCount dw 0 ; nmiCount dw 0
DPSave dw 0 DPSave dw 0
LastAreaType dw 0 LastAreaType dw 0
frameCount dw 0 frameCount dw 0
@ -539,6 +426,136 @@ NESColorToIIgs
bcc :loop bcc :loop
rts rts
; Loop through the tiles and convert them from the NES ROM format into a custom
; format that will be stored in the GTE tile buffer and rendered by the custom
; tile rendering callbacks
LoadTilesFromROM
ldx #0
ldy #0
:tloop
phx
phy
lda #TileBuff
jsr ConvertROMTile2
lda 1,s
pha ; start
inc
pha ; finish
pea #^TileBuff ; pointer
pea #TileBuff
_GTELoadTileSet
ply
iny
pla
clc
adc #16 ; NES tiles are 16 bytes
tax
cpx #512*16
bcc :tloop
rts
; Helper to initialize the GTE playfield based on the selected VideoMode
InitPlayfield
lda #16 ; We render starting at line 16 in the NES video buffer
sta NesTop
lda VideoMode
cmp #0
beq :good
cmp #2
beq :better
lda #0
sta MinYScroll
lda #200
sta ScreenHeight
bra :common
:better
lda #16 ; Keep the GTE playfield below the status bar in PPU RAM
sta MinYScroll
lda #160 ; 160 lines high for 'better'
sta ScreenHeight
bra :common
:good
lda #16 ; Keep the GTE playfield below the status bar in PPU RAM
sta MinYScroll
lda #128 ; Only 128 lines tall for speed
sta ScreenHeight
; Common follow-on initialization
:common
lda ScreenHeight
lsr
lsr
lsr
sta ScreenRows
lda #200 ; Only display down to this row
sec
sbc ScreenHeight
sta MaxYScroll
lda NesTop
clc
adc ScreenHeight
sec
sbc #8
inc
sta NesBottom
; Initialize the graphics screen playfield
pea #128
pei ScreenHeight
_GTESetScreenMode
pha ; Allocate space for x, y, width, height
pha
pha
pha
_GTEGetScreenInfo
pla ; Discard x
pla
sta ScreenTop
asl
asl
asl
asl
asl
sta ScreenBase
asl
asl
clc
adc ScreenBase
clc
adc #$2000+x_offset
sta ScreenBase
pla ; Discard width and height
pla
; Set a default palette for the title screen
ldx #Area1Palette
lda #TmpPalette
jsr NESColorToIIgs
pea $0000
pea #^TmpPalette
pea #TmpPalette
_GTESetPalette
rts
; Helper to perform the essential functions of rendering a frame ; Helper to perform the essential functions of rendering a frame
RenderFrame RenderFrame
@ -591,20 +608,18 @@ RenderFrame
ldal $0000ce,x ; Player_Y_Position ldal $0000ce,x ; Player_Y_Position
and #$00FF and #$00FF
; sta ROMPlayerY
; The "full screen" size is 200 lines that cover NES rows 16 through 216. If the ; The "full screen" size is 200 lines that cover NES rows 16 through 216. If the
; size of the playfield is less, then we adjust the origin a bit. ; size of the playfield is less, then we adjust the origin a bit.
; ;
; Y_Origin = min(200 - ScreenHeight, max(0, ROMPlayerY - 16 - ScreenHeight/2)) ; The goal is to only scroll up once the player is in the top third
; of the screen. It's better to keep an eye on the ground when jumping
;
; Y_Origin = min(200 - ScreenHeight, max(0, ROMPlayerY - NesTop))
sec sec
sbc NesTop sbc NesTop
asl
sec
sbc ScreenHeight
bmi :max_neg bmi :max_neg
lsr
cmp MinYScroll cmp MinYScroll
bcc :max_clamp bcc :max_clamp
@ -629,16 +644,25 @@ RenderFrame
_GTEEnableBackground _GTEEnableBackground
:bghop :bghop
; pea $FFFF ; NES mode lda VideoMode
lda HideStatusBar cmp #4
beq :full_screen beq :full_screen
pea $FFFD pea $FFFD ; Render just the playfield area
_GTERender _GTERender
lda frameCount ; Update the status area once every 8 renders ~1 time per second
sec
sbc LastStatusUdt
cmp #8
bcc :render_done
lda frameCount
sta LastStatusUdt
jsr CopyStatusToScreen
bra :render_done bra :render_done
:full_screen :full_screen
pea $FFFF pea $FFFF ; Render the fixed status bar and playfield
_GTERender _GTERender
:render_done :render_done
@ -653,6 +677,7 @@ RenderFrame
jsr SetAreaType jsr SetAreaType
:no_area_change :no_area_change
inc frameCount ; Tick over to a new frame
rts rts
SetAreaType SetAreaType
@ -686,10 +711,18 @@ SetAreaType
:out :out
rts rts
AreaPalettes dw WaterPalette,Area1Palette,Area2Palette,Area3Palette,Area4Palette AreaPalettes dw WaterPalette,Area1Palette,Area2Palette,Area3Palette,Area2Palette
SwizzleTables adrl AT0_T0,AT1_T0,AT2_T0,AT3_T0,AT2_T0 SwizzleTables adrl AT0_T0,AT1_T0,AT2_T0,AT3_T0,AT2_T0
SwizzlePtr adrl AT1_T0 SwizzlePtr adrl AT1_T0
ClearScreen
ldx #$7CFE
:loop stal $012000,x
dex
dex
bpl :loop
rts
; Draw PPU tiles to the screen for a UI ; Draw PPU tiles to the screen for a UI
; ;
; 0 - 9 starts at tile 256 ; 0 - 9 starts at tile 256
@ -698,40 +731,74 @@ SwizzlePtr adrl AT1_T0
TILE_ZERO equ 256 TILE_ZERO equ 256
TILE_A equ 266 TILE_A equ 266
TILE_SHROOM equ 462 TILE_SHROOM equ 462
TILE_BLANK equ 295
COL_STEP equ 4
ROW_STEP equ {8*160}
_PutTile mac
pea {]1}+TILE_USER_BIT
pea $2000+{]2*COL_STEP}+{]3*ROW_STEP}
pea ]4
_GTEDrawTileToScreen
<<<
_PutStr mac
ldx #]1
ldy #$2000+{]2*COL_STEP}+{]3*ROW_STEP}
jsr ConfigDrawString
<<<
ShowConfig ShowConfig
lda #0 lda #1
jsr SetAreaType jsr SetAreaType
lda #$0000 lda #$0000
stal $E19E00 stal $E19E00
ldx #TILE_SHROOM+TILE_USER_BIT lda #0
jsr ClearScreen
ldx #0 ; Config setting index
:loop :loop
phx phx
cpx #0
beq :video
cpx #1
beq :audio
bra :skip_selector
:video
_PutTile TILE_SHROOM;2;2;1
_PutTile TILE_BLANK;2;7;1
bra :skip_selector
:audio
_PutTile TILE_SHROOM;2;7;1
_PutTile TILE_BLANK;2;2;1
bra :skip_selector
phx :skip_selector
pea $2000 lda #2
pea $0000 ; Bits 1-2, 5 and 7 are valid _PutStr VideoTitle;4;2
_GTEDrawTileToScreen
ldx #msg1 ldx VideoMode
ldy #$2000+{8*160} lda GoodPalette,x
lda #$0000 _PutStr GoodStr;6;4
jsr ConfigDrawString ldx VideoMode
lda BetterPalette,x
_PutStr BetterStr;12;4
ldx VideoMode
lda BestPalette,x
_PutStr BestStr;20;4
ldx #msg1 lda #2
ldy #$2000+{16*160} _PutStr AudioTitle;4;7
lda #$0001
jsr ConfigDrawString
ldx #msg1 ldx AudioMode
ldy #$2000+{24*160} lda GoodPalette,x
lda #$0002 _PutStr GoodStr;6;9
jsr ConfigDrawString ldx AudioMode
lda BetterPalette,x
ldx #msg1 _PutStr BetterStr;12;9
ldy #$2000+{32*160} ldx AudioMode
lda #$0003 lda BestPalette,x
jsr ConfigDrawString _PutStr BestStr;20;9
:waitloop :waitloop
pha pha
@ -742,17 +809,45 @@ ShowConfig
plx plx
and #$007F and #$007F
cmp #LEFT_ARROW cmp #UP_ARROW
beq :decrement beq :decrement
cmp #RIGHT_ARROW cmp #DOWN_ARROW
beq :increment beq :increment
cmp #' '
beq :toggle
cmp #13
bne :waitloop
rts rts
:toggle
cpx #0
beq :toggle_video
lda AudioMode
inc
inc
cmp #6
bcc *+5
lda #0
sta AudioMode
brl :loop
:toggle_video
lda VideoMode
inc
inc
cmp #6
bcc *+5
lda #0
sta VideoMode
brl :loop
:increment :increment
inx ldx #1
inx brl :loop
:decrement dex :decrement ldx #0
bra :loop brl :loop
GoodPalette dw 0,2,2
BetterPalette dw 2,0,2
BestPalette dw 2,2,0
; X = string pointer ; X = string pointer
; Y = address ; Y = address
@ -804,7 +899,14 @@ ConfigDrawString
bne :loop bne :loop
rts rts
msg1 str 'HELLO 123' VideoTitle str 'VIDEO QUALITY'
AudioTitle str 'AUDIO QUALITY'
GoodStr str 'GOOD'
BetterStr str 'BETTER'
BestStr str 'BEST'
VOCTitle str 'ENABLE VOC ACCELERATION'
YesStr str 'YES'
NoStr str 'NO'
; Take a PPU address and convert it to a tile store coordinate ; Take a PPU address and convert it to a tile store coordinate
; ;
@ -1227,11 +1329,8 @@ CopyStatus
inx inx
stx Tmp2 stx Tmp2
; _GTESetTile
_GTESetTileImmediate _GTESetTileImmediate
ply ply
plx plx
@ -1244,6 +1343,46 @@ CopyStatus
bcc :yloop bcc :yloop
rts rts
; Copy just the tiles that change directly tothe graphics screen
MemOffsets dw 67,68,69,70
dw 71,99,100,101
dw 102,103,104
ScreenOffsets dw 12,16,20,24
dw 28,ROW_STEP+12,ROW_STEP+16,ROW_STEP+20
dw ROW_STEP+24,ROW_STEP+28,ROW_STEP+32
CopyStatusToScreen
lda ScreenBase
sec
sbc #160*16
sta Tmp0
ldx #0
:loop
phx ; preserve x
ldy MemOffsets,x
lda PPU_MEM+$2000,y
and #$00FF
ora #$0100+TILE_USER_BIT
pha
lda ScreenOffsets,x
clc
adc Tmp0
pha
pea $8002
_GTEDrawTileToScreen
plx
inx
inx
cpx #11*2
bcc :loop
rts
; Copy the tile and attribute bytes into the GTE buffer ; Copy the tile and attribute bytes into the GTE buffer
; ;
; A = logical column in mirrored PPU memory (0 - 63) ; A = logical column in mirrored PPU memory (0 - 63)
@ -1347,9 +1486,12 @@ CopyNametable
; Trigger an NMI in the ROM ; Trigger an NMI in the ROM
triggerNMI triggerNMI
lda AudioMode
bne :good_audio
sep #$30 sep #$30
jsl quarter_speed_driver jsl quarter_speed_driver
rep #$30 rep #$30
:good_audio
ldal ppuctrl ; If the ROM has not enabled VBL NMI, also skip ldal ppuctrl ; If the ROM has not enabled VBL NMI, also skip
bit #$80 bit #$80
@ -1878,9 +2020,9 @@ StkSave lda #$0000
; VBL Interrupt task (called in native 8-bit mode) ; VBL Interrupt task (called in native 8-bit mode)
mx %11 mx %11
nmiTask nmiTask
ldal nmiCount ; ldal nmiCount
inc ; inc
stal nmiCount ; stal nmiCount
php php
rep #$30 rep #$30
@ -1933,11 +2075,11 @@ readInput
sep #$20 sep #$20
lda 1,s lda 1,s
cmp #'n' cmp #9 ; TAB, was 'n'
bne *+6 bne *+6
lda #$20 lda #$20
bra :nes_merge bra :nes_merge
cmp #'m' cmp #13 ; RETURN, was 'm'
bne *+6 bne *+6
lda #$10 lda #$10
bra :nes_merge bra :nes_merge
@ -1982,15 +2124,16 @@ PPU_OAM ds 256 ; 256 bytes of separate OAM RAM
; ;
; Palettes of NES color indexes ; Palettes of NES color indexes
Area1Palette dw $22, $00, $29, $1A, $0F, $36, $17, $30, $21, $27, $1A, $16, $00, $00, $16, $18 Area1Palette dw $22, $00, $29, $1A, $0F, $36, $17, $30, $21, $27, $1A, $16, $00, $00, $16, $18
Area4Palette
; Underground ; Underground
Area2Palette dw $0F, $00, $29, $1A, $09, $3C, $1C, $30, $21, $17, $27, $36, $16, $1D, $16, $18 Area2Palette dw $0F, $00, $29, $1A, $09, $3C, $1C, $30, $21, $17, $27, $36, $16, $1D, $16, $18
; Castle ; Castle
Area3Palette dw $0F, $00, $30, $10, $00, $16, $17, $27, $1C, $36, $1D, $00, $00, $00, $16, $18 Area3Palette dw $0F, $00, $30, $10, $00, $16, $17, $27, $1C, $36, $1D, $00, $00, $00, $16, $18
; Water
WaterPalette dw $22, $00, $15, $12, $25, $3A, $1A, $0F, $30, $12, $27, $10, $16, $00, $16, $18
WaterPalette dw $22, $00, $15, $12, $25, $3A, $1A, $0F, $30, $12, $27, $10, $16, $00, $16, $18
; Palette remapping ; Palette remapping
put pal_w11.s put pal_w11.s
put apu.s put apu.s

View File

@ -333,8 +333,8 @@ PPUDATA_WRITE ENT
sta nt_queue,y sta nt_queue,y
:full :full
lda #1 ; lda #1
jsr setborder ; jsr setborder
rts rts
:attrtbl :attrtbl
@ -1308,6 +1308,7 @@ oam_loop
phd phd
GTE_DP2 pea $0000 GTE_DP2 pea $0000
pld pld
sec ; Select the secont bank of tiles
jsr drawTileToScreen jsr drawTileToScreen
pld pld
@ -1369,6 +1370,17 @@ jeq mac
jmp ]1 jmp ]1
<<< <<<
NESDirectTileBlitter
asl
and #$0146 ; Set the vflip bit, priority, and palette select bit
bcs :no_mask
jsr drawTileToScreen ; Just a shim since this function is called via JSL
rtl
:no_mask
clc
jsr drawTileToScreen2
rtl
drawTileToScreen drawTileToScreen
stx USER_TILE_ADDR stx USER_TILE_ADDR
@ -1380,10 +1392,16 @@ drawTileToScreen
pha pha
and #$0006 ; Isolate the palette selection bits and #$0006 ; Isolate the palette selection bits
clc
adc #$0008 ; Sprite palettes are in the second half sta USER_FREE_SPACE
lda #0
rol
asl
asl
asl
adc USER_FREE_SPACE
xba xba
clc
adcl SwizzlePtr adcl SwizzlePtr
sta USER_FREE_SPACE sta USER_FREE_SPACE
lda #^AT1_T0 ; Bank is a constant lda #^AT1_T0 ; Bank is a constant
@ -1548,73 +1566,124 @@ drawTileToScreen
plb ; Restore initial data bank plb ; Restore initial data bank
rts rts
:drawPriorityToScreenV
]line equ 0
lup 8
ldx USER_TILE_ADDR
lda: {]line*4}+32+2,x ; Save the inverted mask
eor #$FFFF
sta USER_TEMP_1
ldy: {]line*4}+2,x ; Load the tile data lookup value ;:drawPriorityToScreenV
db LDA_IND_LONG_IDX,USER_FREE_SPACE ; Insert the actual tile data ;]line equ 0
; lup 8
ldx USER_SCREEN_ADDR ; ldx USER_TILE_ADDR
eorl $010000+{{7-]line}*SHR_LINE_WIDTH}+2,x ; lda: {]line*4}plb
sta USER_TEMP_0 ; plb ; Restore initial data bank
; rts+32+2,x ; Save the inverted mask
; eor #$FFFF
; sta USER_TEMP_1
;
; ldy: {]line*4}+2,x ; Load the tile data lookup value
; db LDA_IND_LONG_IDX,USER_FREE_SPACE ; Insert the actual tile data
;
; ldx USER_SCREEN_ADDR
; eorl $010000+{{7-]line}*SHR_LINE_WIDTH}+2,x
; sta USER_TEMP_0
; Convert the screen data to a mask. Zero in screen = zero in mask, else $F ; Convert the screen data to a mask. Zero in screen = zero in mask, else $F
ldal $010000+{{7-]line}*SHR_LINE_WIDTH}+2,x ; ldal $010000+{{7-]line}*SHR_LINE_WIDTH}+2,x
bit #$F000 ; bit #$F000
beq *+5 ; beq *+5
ora #$F000 ; ora #$F000
bit #$0F00 ; bit #$0F00
beq *+5 ; beq *+5
ora #$0F00 ; ora #$0F00
bit #$00F0 ; bit #$00F0
beq *+5 ; beq *+5
ora #$00F0 ; ora #$00F0
bit #$000F ; bit #$000F
beq *+5 ; beq *+5
ora #$000F ; ora #$000F
eor #$FFFF ; eor #$FFFF
and USER_TEMP_0 ; and USER_TEMP_0
and USER_TEMP_1 ; and USER_TEMP_1
eorl $010000+{{7-]line}*SHR_LINE_WIDTH}+2,x ; eorl $010000+{{7-]line}*SHR_LINE_WIDTH}+2,x
stal $010000+{{7-]line}*SHR_LINE_WIDTH}+2,x ; stal $010000+{{7-]line}*SHR_LINE_WIDTH}+2,x
ldx USER_TILE_ADDR ; ldx USER_TILE_ADDR
lda: {]line*4}+32,x ; Save the inverted mask ; lda: {]line*4}+32,x ; Save the inverted mask
eor #$FFFF ; eor #$FFFF
sta USER_TEMP_1 ; sta USER_TEMP_1
ldy: {]line*4},x ; Load the tile data lookup value ; ldy: {]line*4},x ; Load the tile data lookup value
db LDA_IND_LONG_IDX,USER_FREE_SPACE ; Insert the actual tile data ; db LDA_IND_LONG_IDX,USER_FREE_SPACE ; Insert the actual tile data
; ldx USER_SCREEN_ADDR
; eorl $010000+{{7-]line}*SHR_LINE_WIDTH},x
; sta USER_TEMP_0
; ldal $010000+{{7-]line}*SHR_LINE_WIDTH},x
; bit #$F000
; beq *+5
; ora #$F000
; bit #$0F00
; beq *+5
; ora #$0F00
; bit #$00F0
; beq *+5
; ora #$00F0
; bit #$000F
; beq *+5
; ora #$000F
; eor #$FFFF
; and USER_TEMP_0
; and USER_TEMP_1
; eorl $010000+{{7-]line}*SHR_LINE_WIDTH},x
; stal $010000+{{7-]line}*SHR_LINE_WIDTH},x
;]line equ ]line+1
--^
; plb
; plb ; Restore initial data bank
; rts
; Draw to the screen without any mask
drawTileToScreen2
stx USER_TILE_ADDR
sty USER_SCREEN_ADDR
phb
pei DP2_TILEDATA_AND_BANK01_BANKS
plb
and #$0006 ; Isolate the palette selection bits
sta USER_FREE_SPACE
lda #0
rol
asl
asl
asl
adc USER_FREE_SPACE
xba
adcl SwizzlePtr
sta USER_FREE_SPACE
lda #^AT1_T0 ; Bank is a constant
sta USER_FREE_SPACE+2 ; Set the pointer to the right swizzle table
; brk $55
ldx USER_SCREEN_ADDR ldx USER_SCREEN_ADDR
eorl $010000+{{7-]line}*SHR_LINE_WIDTH},x ]line equ 0
sta USER_TEMP_0 lup 8
ldy #{]line*4}
lda (USER_TILE_ADDR),y
tay
db LDA_IND_LONG_IDX,USER_FREE_SPACE
stal $010000+{]line*SHR_LINE_WIDTH},x
ldal $010000+{{7-]line}*SHR_LINE_WIDTH},x ldy #{]line*4}+2
bit #$F000 lda (USER_TILE_ADDR),y
beq *+5 tay
ora #$F000 db LDA_IND_LONG_IDX,USER_FREE_SPACE
bit #$0F00 stal $010000+{]line*SHR_LINE_WIDTH}+2,x
beq *+5
ora #$0F00
bit #$00F0
beq *+5
ora #$00F0
bit #$000F
beq *+5
ora #$000F
eor #$FFFF
and USER_TEMP_0
and USER_TEMP_1
eorl $010000+{{7-]line}*SHR_LINE_WIDTH},x
stal $010000+{{7-]line}*SHR_LINE_WIDTH},x
]line equ ]line+1 ]line equ ]line+1
--^ --^

View File

@ -2615,11 +2615,11 @@ JumpEngine
sta $05 sta $05
iny iny
lda ($04),y ;load pointer from indirect lda ($04),y ;load pointer from indirect
sta $06 ;note that if an RTS is performed in next routine ; sta $06 ;note that if an RTS is performed in next routine
sta :je_patch+1 sta :je_patch+1
iny ;it will return to the execution before the sub iny ;it will return to the execution before the sub
lda ($04),y ;that called this routine lda ($04),y ;that called this routine
sta $07 ; sta $07
sta :je_patch+2 sta :je_patch+2
; jmp ($06) ;jump to the address we loaded ; jmp ($06) ;jump to the address we loaded
@ -3020,22 +3020,21 @@ InitializeMemory
ldx #$07 ;set initial high byte to $0700-$07ff ldx #$07 ;set initial high byte to $0700-$07ff
lda #$00 ;set initial low byte to start of page (at $00 of page) lda #$00 ;set initial low byte to start of page (at $00 of page)
sta $06 sta $06
InitPageLoop stx $07 InitPageLoop stx $07
InitByteLoop cpx #$01 ;check to see if we're on the stack ($0100-$01ff) InitByteLoop cpx #$01 ;check to see if we're on the stack ($0100-$01ff)
bne InitByte ;if not, go ahead anyway bne InitByte ;if not, go ahead anyway
cpy #$60 ;otherwise, check to see if we're at $0160-$01ff cpy #$60 ;otherwise, check to see if we're at $0160-$01ff
bcs SkipByte ;if so, skip write bcs SkipByte ;if so, skip write
InitByte sta ($06),y ;otherwise, initialize byte with current low byte in Y InitByte sta ($06),y ;otherwise, initialize byte with current low byte in Y
SkipByte dey SkipByte dey
cpy #$ff ;do this until all bytes in page have been erased cpy #$ff ;do this until all bytes in page have been erased
bne InitByteLoop bne InitByteLoop
dex ;go onto the next page dex ;go onto the next page
; bpl InitPageLoop ;do this until all pages of memory have been erased ; bpl InitPageLoop ;do this until all pages of memory have been erased
; rts ; rts
cpx #$02 ;GTE wrapper -- zero page and stack are in a different
cpx #$02 ;GTE wrapper -- zero page and stack are in a different bcs InitPageLoop ;bank, so we provide a little help here
bcs InitPageLoop ;bank, so we provide a little help here jmp GteInitMem
jmp GteInitMem
;------------------------------------------------------------------------------------- ;-------------------------------------------------------------------------------------
@ -7238,7 +7237,7 @@ SetHSpd lda #$fe
SetHPos dec Misc_State,x ;decrement hammer's state SetHPos dec Misc_State,x ;decrement hammer's state
stx GTE_TMP stx GTE_TMP
; lda Enemy_X_Position,y ;get enemy's horizontal position ; lda Enemy_X_Position,y ;get enemy's horizontal position
tyx tyx
lda Enemy_X_Position,x lda Enemy_X_Position,x
ldx GTE_TMP ldx GTE_TMP