mirror of
https://github.com/digarok/MiniMemoryTester.git
synced 2024-06-07 04:29:27 +00:00
finally fixed int input (dirty buffer artifact)
This commit is contained in:
parent
ba62ca4ac4
commit
13f5162eab
266
src/menu.s
266
src/menu.s
|
@ -143,8 +143,63 @@ _menuBoolOnStr asc " on",00
|
||||||
_menuBoolOffStr asc "off",00
|
_menuBoolOffStr asc "off",00
|
||||||
* @todo make this more configurable
|
* @todo make this more configurable
|
||||||
|
|
||||||
Menu_DrawOptionInt rts
|
Menu_DrawOptionInt iny
|
||||||
|
lda ($F0),y ;get len
|
||||||
|
sta _menuOptionLen
|
||||||
|
iny
|
||||||
|
lda ($F0),y ;get da
|
||||||
|
sta $F2 ;storez
|
||||||
|
iny
|
||||||
|
lda ($F0),y ;get da
|
||||||
|
sta $F3 ;storez
|
||||||
|
|
||||||
|
ldy #0
|
||||||
|
lda ($F2),y
|
||||||
|
tax
|
||||||
|
iny
|
||||||
|
lda ($F2),y
|
||||||
|
tay
|
||||||
|
|
||||||
|
|
||||||
|
;convert to BCD
|
||||||
|
jsr BINtoBCD
|
||||||
|
|
||||||
|
|
||||||
|
stx _menuBCDInt+1
|
||||||
|
sty _menuBCDInt
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
ldy #0
|
||||||
|
ldx #0
|
||||||
|
lda _menuOptionLen
|
||||||
|
lsr
|
||||||
|
bcs :oddmax
|
||||||
|
|
||||||
|
:prloop lda _menuBCDInt,y
|
||||||
|
lsr
|
||||||
|
lsr
|
||||||
|
lsr
|
||||||
|
lsr
|
||||||
|
phy
|
||||||
|
phx
|
||||||
|
jsr PRHEX
|
||||||
|
plx
|
||||||
|
ply
|
||||||
|
inx
|
||||||
|
:oddmax lda _menuBCDInt,y
|
||||||
|
and #$0F
|
||||||
|
phy
|
||||||
|
phx
|
||||||
|
jsr PRHEX
|
||||||
|
plx
|
||||||
|
ply
|
||||||
|
inx
|
||||||
|
iny
|
||||||
|
cpx _menuOptionLen
|
||||||
|
bne :prloop
|
||||||
|
rts
|
||||||
|
_menuBCDInt ds 4
|
||||||
Menu_DrawOptionHex iny
|
Menu_DrawOptionHex iny
|
||||||
lda ($F0),y ;get len
|
lda ($F0),y ;get len
|
||||||
sta _menuOptionLen
|
sta _menuOptionLen
|
||||||
|
@ -268,8 +323,7 @@ Menu_GetItemScreenWidth
|
||||||
:notBin cpx Menu_TypeInt
|
:notBin cpx Menu_TypeInt
|
||||||
bne :notInt
|
bne :notInt
|
||||||
rts ;input width... internally maxint = FFFF
|
rts ;input width... internally maxint = FFFF
|
||||||
:notInt cpx Menu_TypeAction
|
:notInt bne :notAction
|
||||||
bne :notAction
|
|
||||||
rts ;should be defined in param from string length
|
rts ;should be defined in param from string length
|
||||||
:notAction cpx Menu_TypeList
|
:notAction cpx Menu_TypeList
|
||||||
bne :notList
|
bne :notList
|
||||||
|
@ -333,13 +387,13 @@ _menuSelectedY db 0
|
||||||
* THESE ARE ALL OF THE MENU INPUT TYPES
|
* THESE ARE ALL OF THE MENU INPUT TYPES
|
||||||
Menu_Inputs
|
Menu_Inputs
|
||||||
Menu_InputTable da Menu_InputChar,Menu_InputHex,Menu_InputAction,Menu_InputList,Menu_InputBool,Menu_InputBin,Menu_InputInt
|
Menu_InputTable da Menu_InputChar,Menu_InputHex,Menu_InputAction,Menu_InputList,Menu_InputBool,Menu_InputBin,Menu_InputInt
|
||||||
Menu_TypeChar equ #0
|
Menu_TypeChar equ #0
|
||||||
Menu_TypeHex equ #1
|
Menu_TypeHex equ #1
|
||||||
Menu_TypeBin equ #5
|
Menu_TypeBin equ #5
|
||||||
Menu_TypeInt equ #6
|
Menu_TypeInt equ #6
|
||||||
Menu_TypeAction equ #2
|
Menu_TypeAction equ #2
|
||||||
Menu_TypeList equ #3
|
Menu_TypeList equ #3
|
||||||
Menu_TypeBool equ #4
|
Menu_TypeBool equ #4
|
||||||
|
|
||||||
|
|
||||||
* $0 = ptr->MenuDefs
|
* $0 = ptr->MenuDefs
|
||||||
|
@ -383,7 +437,30 @@ Menu_InputBool tay
|
||||||
|
|
||||||
|
|
||||||
Menu_InputBin rts
|
Menu_InputBin rts
|
||||||
Menu_InputInt rts
|
Menu_InputInt pha
|
||||||
|
tay
|
||||||
|
lda ($F0),y
|
||||||
|
tax
|
||||||
|
iny
|
||||||
|
lda ($F0),y
|
||||||
|
tay
|
||||||
|
jsr GoXY
|
||||||
|
pla
|
||||||
|
clc
|
||||||
|
adc #3 ;get max input length for int
|
||||||
|
tay ; |
|
||||||
|
lda ($F0),y ; |
|
||||||
|
pha ; store length
|
||||||
|
iny
|
||||||
|
lda ($F0),y ;get low nibble of storage location
|
||||||
|
pha ; store low nibble
|
||||||
|
iny
|
||||||
|
lda ($F0),y ;get high nibble of storage location
|
||||||
|
tay
|
||||||
|
plx ;get low nibble
|
||||||
|
pla ;get length
|
||||||
|
jsr GetInt
|
||||||
|
rts
|
||||||
|
|
||||||
Menu_InputHex pha
|
Menu_InputHex pha
|
||||||
tay
|
tay
|
||||||
|
@ -443,6 +520,7 @@ Menu_InputList
|
||||||
rts
|
rts
|
||||||
*** INPUT LIBRARY FOR MENU
|
*** INPUT LIBRARY FOR MENU
|
||||||
* Pass desired length in A
|
* Pass desired length in A
|
||||||
|
* x/y= storage area
|
||||||
GetHex
|
GetHex
|
||||||
sta _gethex_maxlen
|
sta _gethex_maxlen
|
||||||
stx _gethex_resultptr
|
stx _gethex_resultptr
|
||||||
|
@ -531,19 +609,136 @@ _gethex_maxlen db 1
|
||||||
_gethex_current db 0
|
_gethex_current db 0
|
||||||
_gethex_buffer ds _gethex_internalmax
|
_gethex_buffer ds _gethex_internalmax
|
||||||
_gethex_screenx db 0
|
_gethex_screenx db 0
|
||||||
PrHexChar jsr HexCharForByte
|
|
||||||
|
|
||||||
HexCharForByte
|
*** INPUT LIBRARY FOR MENU
|
||||||
cmp #9
|
* Pass desired length in A
|
||||||
bcs :alpha
|
* x/y= storage area
|
||||||
:number clc
|
GetInt
|
||||||
adc #"0"
|
sta _getint_maxlen
|
||||||
|
stx _getint_resultptr
|
||||||
|
sty _getint_resultptr+1
|
||||||
|
stz _getint_current
|
||||||
|
lda $24
|
||||||
|
sta _getint_screenx ;stash x. gets clobbered by RDKEY
|
||||||
|
ldx _getint_maxlen
|
||||||
|
:clearbuffer dex ;we need to zero our buffer
|
||||||
|
stz _getint_buffer,x ;
|
||||||
|
bne :clearbuffer ;
|
||||||
|
|
||||||
|
:input jsr RDKEY
|
||||||
|
|
||||||
|
cmp #KEY_ESC ;9B = abort
|
||||||
|
bne :notesc
|
||||||
rts
|
rts
|
||||||
:alpha clc
|
:notesc cmp #KEY_DEL ;del
|
||||||
adc #"A"
|
beq :goBack
|
||||||
|
cmp #KEY_LTARROW
|
||||||
|
bne :notBack
|
||||||
|
:goBack
|
||||||
|
lda _getint_current
|
||||||
|
beq :badChar ; otherwise result = -1
|
||||||
|
dec _getint_current
|
||||||
|
dec _getint_screenx
|
||||||
|
GOXY _getint_screenx;$25
|
||||||
|
bra :input
|
||||||
|
:notBack cmp #"9"+1
|
||||||
|
bcs :badChar ;bge > 9
|
||||||
|
cmp #"0"
|
||||||
|
bcc :badChar ;
|
||||||
|
sec
|
||||||
|
sbc #"0"
|
||||||
|
bra :storeInput
|
||||||
|
:badChar jmp :input
|
||||||
|
:storeInput
|
||||||
|
pha
|
||||||
|
jsr PRHEX
|
||||||
|
pla
|
||||||
|
ldy _getint_current
|
||||||
|
sta _getint_buffer,y
|
||||||
|
inc _getint_screenx
|
||||||
|
iny
|
||||||
|
cpy #_getint_internalmax
|
||||||
|
bge :internalmax
|
||||||
|
cpy _getint_maxlen
|
||||||
|
bge :passedmax
|
||||||
|
sty _getint_current
|
||||||
|
bra :input
|
||||||
|
:internalmax
|
||||||
|
:passedmax
|
||||||
|
lda _getint_resultptr
|
||||||
|
sta $0
|
||||||
|
lda _getint_resultptr+1
|
||||||
|
sta $1
|
||||||
|
ldy #0 ;clear any existing data (otherwise OR mask error with odd input lengths)
|
||||||
|
tya
|
||||||
|
sta ($0),y
|
||||||
|
iny
|
||||||
|
sta ($0),y
|
||||||
|
ldx #0
|
||||||
|
ldy #0
|
||||||
|
lda _getint_maxlen
|
||||||
|
lsr
|
||||||
|
bcs :oddmax
|
||||||
|
:copyBuffer lda _getint_buffer,x
|
||||||
|
asl ; move to upper nibble
|
||||||
|
asl
|
||||||
|
asl
|
||||||
|
asl
|
||||||
|
sta ($0),y ; store
|
||||||
|
inx
|
||||||
|
:oddmax lda _getint_buffer,x
|
||||||
|
ora ($0),y
|
||||||
|
sta ($0),y
|
||||||
|
iny
|
||||||
|
inx
|
||||||
|
cpx _getint_maxlen
|
||||||
|
bcc :copyBuffer ;done copying to buffer like "0123" (still decimal)
|
||||||
|
|
||||||
|
ldy #$1 ;@todo this is all wonky and a bit hackish
|
||||||
|
lda ($0),y
|
||||||
|
tax
|
||||||
|
dey
|
||||||
|
lda ($0),y
|
||||||
|
tay
|
||||||
|
jsr BCDtoBIN
|
||||||
|
tya
|
||||||
|
ldy #1
|
||||||
|
sta ($0),y
|
||||||
|
dey
|
||||||
|
txa
|
||||||
|
sta ($0),y
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
_getint_internalmax equ 4
|
||||||
|
_getint_resultptr da 0000
|
||||||
|
_getint_maxlen db 1
|
||||||
|
_getint_current db 0
|
||||||
|
_getint_buffer ds _getint_internalmax
|
||||||
|
_getint_screenx db 0
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
* x/y = high/low
|
||||||
|
BINtoBCD stx BIN
|
||||||
|
sty BIN+1
|
||||||
|
jsr BINBCD16
|
||||||
|
ldx BCD
|
||||||
|
ldy BCD+1
|
||||||
|
rts
|
||||||
|
BCDtoBIN
|
||||||
|
stx BCD
|
||||||
|
sty BCD+1
|
||||||
|
jsr BCDBIN16
|
||||||
|
ldx BIN
|
||||||
|
ldy BIN+1
|
||||||
|
rts
|
||||||
|
|
||||||
|
BIN dw $0000
|
||||||
|
BCD ds 3
|
||||||
|
|
||||||
BINBCD16 SED ; Switch to decimal mode
|
BINBCD16 SED ; Switch to decimal mode
|
||||||
LDA #0 ; Ensure the result is clear
|
LDA #0 ; Ensure the result is clear
|
||||||
STA BCD+0
|
STA BCD+0
|
||||||
|
@ -565,12 +760,12 @@ BINBCD16 SED ; Switch to decimal
|
||||||
DEX ; And repeat for next bit
|
DEX ; And repeat for next bit
|
||||||
BNE :CNVBIT
|
BNE :CNVBIT
|
||||||
CLD ; Back to binary
|
CLD ; Back to binary
|
||||||
RTS
|
rts
|
||||||
BIN dw $03e7
|
|
||||||
BCD ds 3
|
|
||||||
|
|
||||||
* 16-bit mode!!!
|
* 16-bit mode!!!
|
||||||
BCDBIN16 clc
|
BCDBIN16
|
||||||
|
clc
|
||||||
xce
|
xce
|
||||||
rep #$30
|
rep #$30
|
||||||
stz BIN
|
stz BIN
|
||||||
|
@ -609,17 +804,34 @@ BCDBIN16 clc
|
||||||
adc BIN
|
adc BIN
|
||||||
sta BIN
|
sta BIN
|
||||||
sep #$30
|
sep #$30
|
||||||
RTS
|
rts
|
||||||
|
|
||||||
|
mx %00
|
||||||
* 16-bit mode!!!
|
* 16-bit mode!!!
|
||||||
TIMES10
|
TIMES10
|
||||||
sta :tensadd+1
|
sta :tensadd+1
|
||||||
ldx #10 ;m*10
|
ldx #9 ;9 loops since because initial value already in M
|
||||||
:tensloop clc
|
:tensloop clc
|
||||||
:tensadd adc #$0000 ;placeholder, gets overwritten above
|
:tensadd adc #$0000 ;placeholder, gets overwritten above
|
||||||
dex
|
dex
|
||||||
bne :tensloop
|
bne :tensloop
|
||||||
RTS
|
rts
|
||||||
|
|
||||||
|
|
||||||
mx %00
|
mx %11
|
||||||
|
BINBCDVARDUMP
|
||||||
|
lda BIN+1
|
||||||
|
jsr PRBYTE
|
||||||
|
lda BIN
|
||||||
|
jsr PRBYTE
|
||||||
|
lda #" "
|
||||||
|
jsr COUT
|
||||||
|
lda BCD+2
|
||||||
|
jsr PRBYTE
|
||||||
|
lda BCD+1
|
||||||
|
jsr PRBYTE
|
||||||
|
lda BCD
|
||||||
|
jsr PRBYTE
|
||||||
|
jsr RDKEY
|
||||||
|
rts
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
MLI equ $bf00
|
MLI equ $bf00
|
||||||
Init
|
Init
|
||||||
|
|
||||||
jsr BINBCD16
|
|
||||||
sei ; disable interrupts
|
sei ; disable interrupts
|
||||||
LDA #$A0 ;USE A BLANK SPACE TO
|
LDA #$A0 ;USE A BLANK SPACE TO
|
||||||
JSR $C300 ;TURN ON THE VIDEO FIRMWARE
|
JSR $C300 ;TURN ON THE VIDEO FIRMWARE
|
||||||
|
@ -634,7 +633,7 @@ HexPattern dw #$0000
|
||||||
TestDirection dw #0 ; list
|
TestDirection dw #0 ; list
|
||||||
TestParallel dw #0 ; bool is byte, but might change in future? :P
|
TestParallel dw #0 ; bool is byte, but might change in future? :P
|
||||||
TestAdjacentWrite dw #0 ; bool is byte, but might change in future? :P
|
TestAdjacentWrite dw #0 ; bool is byte, but might change in future? :P
|
||||||
TestRefreshPause dw #$01 ; int
|
TestRefreshPause dw #$03e7 ; int
|
||||||
TestReadRepeat dw #$01 ; int
|
TestReadRepeat dw #$01 ; int
|
||||||
TestWriteRepeat dw #$01 ; int
|
TestWriteRepeat dw #$01 ; int
|
||||||
TestIterations dw #$00 ; int
|
TestIterations dw #$00 ; int
|
||||||
|
@ -698,7 +697,7 @@ MainMenuDefs
|
||||||
da TestAdjacentWrite ; variable storage
|
da TestAdjacentWrite ; variable storage
|
||||||
:TestRefreshPause hex 28,0C ; x,y
|
:TestRefreshPause hex 28,0C ; x,y
|
||||||
db Menu_TypeInt ; 1=hex input
|
db Menu_TypeInt ; 1=hex input
|
||||||
db 01 ; memory size (bytes)
|
db 03 ; display/entry width. ints are 16-bit internally
|
||||||
da TestRefreshPause ; variable storage
|
da TestRefreshPause ; variable storage
|
||||||
:ReadRepeat hex 12,0D ; x,y
|
:ReadRepeat hex 12,0D ; x,y
|
||||||
db Menu_TypeInt ; 1=hex input
|
db Menu_TypeInt ; 1=hex input
|
||||||
|
@ -739,7 +738,7 @@ MainMenuStrs
|
||||||
asc $1B,'ZZ'," Direction [ ] Parallel R/W [ ] ",'_'," ",'Z'," ",'_'," ",'_',$18,00
|
asc $1B,'ZZ'," Direction [ ] Parallel R/W [ ] ",'_'," ",'Z'," ",'_'," ",'_',$18,00
|
||||||
asc $1B,'ZZ'," Adjacent Wr. [ ] Refresh Pause [000] ",'_'," ",'Z'," ",'_'," ",'_',$18,00
|
asc $1B,'ZZ'," Adjacent Wr. [ ] Refresh Pause [000] ",'_'," ",'Z'," ",'_'," ",'_',$18,00
|
||||||
asc $1B,'ZZ'," Read Repeat [000] Write Repeat [000] ",'_'," ",'Z'," ",'_'," ",'_',$18,00
|
asc $1B,'ZZ'," Read Repeat [000] Write Repeat [000] ",'_'," ",'Z'," ",'_'," ",'_',$18,00
|
||||||
asc $1B,'ZZ'," Iterations [000] ",'_'," ",'Z'," ",'_'," ",'_',$18,00
|
asc $1B,'ZZ'," Iterations [ ] ",'_'," ",'Z'," ",'_'," ",'_',$18,00
|
||||||
asc $1B,'ZZ'," ( ) ",'_'," ",'Z'," ",'_'," ",'_',$18,00
|
asc $1B,'ZZ'," ( ) ",'_'," ",'Z'," ",'_'," ",'_',$18,00
|
||||||
asc $1B,'ZLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL_',$18,00
|
asc $1B,'ZLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL_',$18,00
|
||||||
asc $1B,'Z'," ",'_',$18,00
|
asc $1B,'Z'," ",'_',$18,00
|
||||||
|
|
Loading…
Reference in New Issue
Block a user