mirror of
https://github.com/a2-4am/4cade.git
synced 2025-01-12 14:30:29 +00:00
refactor textrank to use more zero page
This commit is contained in:
parent
340d728ff0
commit
d6358262cb
@ -9,7 +9,7 @@
|
||||
; D000..E5F4 - persistent data structures (per-game cheat categories,
|
||||
; gGlobalPrefsStore, gGamesListStore)
|
||||
; ...unused...
|
||||
; EC56..FFF9 - main program code
|
||||
; EC79..FFF9 - main program code
|
||||
; FFFA..FFFF - NMI, reset, IRQ vectors
|
||||
;
|
||||
; LC RAM BANK 2
|
||||
@ -56,6 +56,14 @@ ROM_NORMAL = $FE84 ; NORMAL text (instead of INVERSE or FLASH)
|
||||
ROM_IN0 = $FE89 ; SETKBD
|
||||
ROM_PR0 = $FE93 ; SETVID
|
||||
|
||||
; zero page during init ONLY
|
||||
zpMachineStatus= $F0 ; bit 7 = 1 if machine has joystick
|
||||
; bit 6 = 1 if machine has 128K
|
||||
; bit 5 = 1 if machine has a VidHD card
|
||||
; bit 4 = 1 if machine is a IIgs
|
||||
; only used during init, then copied to MachineStatus in LC RAM
|
||||
zpCharMask = $F1 ; only uesd during init, then clobbered
|
||||
|
||||
; zero page
|
||||
PARAM = $00 ; word (used by PARAMS_ON_STACK macro, so basically everywhere)
|
||||
PTR = $02 ; word
|
||||
@ -65,16 +73,27 @@ SAVE = $08 ; word
|
||||
KEYLEN = $0A ; byte
|
||||
VALUELEN = $0B ; byte
|
||||
MAX = $0C ; byte
|
||||
HTAB = $24
|
||||
VTAB = $25
|
||||
HTAB = $24 ; byte
|
||||
VTAB = $25 ; byte
|
||||
RNDSEED = $4E ; word
|
||||
; textrank
|
||||
tmpx = $E7 ; byte
|
||||
remainder = $E8 ; word
|
||||
num1 = $EA ; word
|
||||
num2 = $EC ; byte
|
||||
Timeout = $ED ; 3 bytes (used by SearchMode)
|
||||
zpMachineStatus= $F0 ; bit 7 = 1 if machine has joystick
|
||||
; bit 6 = 1 if machine has 128K
|
||||
; bit 5 = 1 if machine has a VidHD card
|
||||
; bit 4 = 1 if machine is a IIgs
|
||||
; only used during init, then copied to MachineStatus in LC RAM
|
||||
zpCharMask = $F1 ; only uesd during init, then clobbered
|
||||
zpword = $F0 ; word
|
||||
zpstring = $F2 ; word
|
||||
runningscore= $F4 ; word
|
||||
startat = $F6 ; byte
|
||||
i = $F7 ; byte
|
||||
tmp = $F8 ; byte
|
||||
gamelength= $F9 ; byte
|
||||
firstletter= $FA ; byte
|
||||
MatchCount = $FB ; byte
|
||||
BestMatchScore = $FC ; byte
|
||||
BestMatchIndex = $FD ; byte
|
||||
|
||||
; $FE ; used by ParseGamesList
|
||||
; $FF ; used by ParseGamesList
|
||||
|
||||
|
@ -15,26 +15,11 @@
|
||||
; - BestMatchScore ; [byte] raw ranking score (0-100) of current best match (updated during TextRankCallback)
|
||||
; - BestMatchIndex ; [byte] index in gGamesListStore of current best match (updated during TextRankCallback)
|
||||
|
||||
zpword = $F0 ; word
|
||||
zpstring = $F2 ; word
|
||||
runningscore= $F4 ; word
|
||||
startat = $F6 ; byte
|
||||
i = $F7 ; byte
|
||||
tmp = $F8 ; byte
|
||||
gamelength= $F9 ; byte
|
||||
firstletter= $FA ; byte
|
||||
|
||||
MaxInputLength = 26
|
||||
InputLength
|
||||
!byte 0
|
||||
InputBuffer
|
||||
!text " "
|
||||
MatchCount
|
||||
!byte 0
|
||||
BestMatchScore
|
||||
!byte 0
|
||||
BestMatchIndex
|
||||
!byte 0
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; ResetTextRank
|
||||
@ -65,7 +50,7 @@ ResetTextRank
|
||||
; was the best match so far)
|
||||
;------------------------------------------------------------------------------
|
||||
TextRankCallback
|
||||
stx @tmpx ; X = OKVS index of this title
|
||||
stx tmpx ; X = OKVS index of this title
|
||||
+STAY zpstring ; A/Y = address of this title
|
||||
+LDADDR InputLength
|
||||
+STAY zpword
|
||||
@ -92,8 +77,7 @@ TextRankCallback
|
||||
iny
|
||||
bcc --
|
||||
++ rts ; no match :(
|
||||
+
|
||||
ldx #80
|
||||
+ ldx #80
|
||||
cpy startat
|
||||
beq +
|
||||
ldx #10
|
||||
@ -121,9 +105,7 @@ TextRankCallback
|
||||
cmp gamelength
|
||||
bcc -
|
||||
rts ; no match :(
|
||||
|
||||
+
|
||||
lda runningscore
|
||||
+ lda runningscore
|
||||
ldx runningscore+1
|
||||
ldy gamelength
|
||||
jsr @div
|
||||
@ -147,43 +129,35 @@ TextRankCallback
|
||||
cmp #85
|
||||
bcs +
|
||||
adc #15
|
||||
+
|
||||
cmp BestMatchScore
|
||||
+ cmp BestMatchScore
|
||||
bcc +
|
||||
beq +
|
||||
sta BestMatchScore
|
||||
ldx @tmpx
|
||||
ldx tmpx
|
||||
stx BestMatchIndex
|
||||
inc MatchCount
|
||||
+
|
||||
rts
|
||||
+ rts
|
||||
|
||||
@div
|
||||
sta @num1
|
||||
stx @num1+1
|
||||
sty @num2
|
||||
|
||||
sta num1
|
||||
stx num1+1
|
||||
sty num2
|
||||
lda #0
|
||||
sta @rem
|
||||
sta @rem+1
|
||||
sta remainder
|
||||
sta remainder+1
|
||||
ldx #16
|
||||
- asl @num1
|
||||
rol @num1+1
|
||||
rol @rem
|
||||
rol @rem+1
|
||||
lda @rem
|
||||
- asl num1
|
||||
rol num1+1
|
||||
rol remainder
|
||||
rol remainder+1
|
||||
lda remainder
|
||||
sec
|
||||
sbc @num2
|
||||
sbc num2
|
||||
bcc +
|
||||
sta @rem
|
||||
dec @rem+1
|
||||
inc @num1
|
||||
sta remainder
|
||||
dec remainder+1
|
||||
inc num1
|
||||
+ dex
|
||||
bne -
|
||||
lda @num1
|
||||
lda num1
|
||||
rts
|
||||
|
||||
@rem !word 0
|
||||
@num1 !word 0
|
||||
@num2 !byte 0
|
||||
@tmpx !byte $FD
|
||||
|
Loading…
x
Reference in New Issue
Block a user