add byte order hex entry for 6502 addressing

This commit is contained in:
Dagen Brock 2015-10-12 21:22:32 -05:00
parent 770d666d28
commit 5f1909a25b
3 changed files with 895 additions and 777 deletions

View File

@ -67,6 +67,7 @@ Menu_DrawRoutinesTbl da Menu_DrawOptionHex ;char
da Menu_DrawOptionBool da Menu_DrawOptionBool
da Menu_DrawOptionBin da Menu_DrawOptionBin
da Menu_DrawOptionInt da Menu_DrawOptionInt
da Menu_DrawOptionHexByteOrder
Menu_DrawOptionBin iny Menu_DrawOptionBin iny
lda ($F0),y ;get len lda ($F0),y ;get len
sta _menuOptionLen sta _menuOptionLen
@ -216,6 +217,22 @@ Menu_DrawOptionHex iny
cpy _menuOptionLen cpy _menuOptionLen
bne :prloop bne :prloop
rts rts
Menu_DrawOptionHexByteOrder 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 _menuOptionLen ;we start at n-1 and work down to 0
:prloop dey
lda ($F2),y
jsr PRBYTE
cpy #0
bne :prloop
rts
Menu_DrawOptionAction iny Menu_DrawOptionAction iny
iny iny
@ -332,7 +349,11 @@ Menu_GetItemScreenWidth
bne :notBool bne :notBool
lda #3 ;@todo: we'll use "off"/"on" for now.. revisit? lda #3 ;@todo: we'll use "off"/"on" for now.. revisit?
rts ;hmm.. undefined? @TODO!!! rts ;hmm.. undefined? @TODO!!!
:notBool :notBool cpx Menu_TypeHexByteOrder
bne :notHexByteOrder
asl ;*2 for printing 2 char per byte
rts
:notHexByteOrder
:wtf :wtf
rts rts
@ -386,9 +407,10 @@ _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_InputHexByteOrder
Menu_TypeChar equ #0 Menu_TypeChar equ #0
Menu_TypeHex equ #1 Menu_TypeHex equ #1
Menu_TypeHexByteOrder equ #7
Menu_TypeBin equ #5 Menu_TypeBin equ #5
Menu_TypeInt equ #6 Menu_TypeInt equ #6
Menu_TypeAction equ #2 Menu_TypeAction equ #2
@ -462,6 +484,32 @@ Menu_InputInt pha
jsr GetInt jsr GetInt
rts rts
Menu_InputHexByteOrder pha
tay
lda ($F0),y
tax
iny
lda ($F0),y
tay
jsr GoXY
pla
clc
adc #3 ; ->memory size
tay
lda ($F0),y
asl ;*2
pha
iny
lda ($F0),y
pha
iny
lda ($F0),y
tay
plx
pla
jsr GetHexByteOrder
rts
Menu_InputHex pha Menu_InputHex pha
tay tay
lda ($F0),y lda ($F0),y
@ -546,7 +594,15 @@ Menu_InputList
*** INPUT LIBRARY FOR MENU *** INPUT LIBRARY FOR MENU
* Pass desired length in A * Pass desired length in A
* x/y= storage area * x/y= storage area
GetHex GetHexByteOrder
pha
lda #$1 ;1=6502 ordering
sta _gethex_byteorder
pla
bra GetHexStart
GetHex stz _gethex_byteorder ;0=linear order (01 23 45 67 etc, in memory)
GetHexStart
sta _gethex_maxlen sta _gethex_maxlen
stx _gethex_resultptr stx _gethex_resultptr
sty _gethex_resultptr+1 sty _gethex_resultptr+1
@ -585,6 +641,10 @@ GetHex
bcc :badChar bcc :badChar
cmp #"F"+1 cmp #"F"+1
bcs :badChar bcs :badChar
bcc :gotHex
***
:badChar jmp :input ;jmp out of here
***
:gotHex :gotHex
sec sec
sbc #"A"-10 sbc #"A"-10
@ -604,11 +664,37 @@ GetHex
bra :input bra :input
:internalmax :internalmax
:passedmax :passedmax
lda _gethex_resultptr lda _gethex_resultptr ;set destination buffer to result memory
sta $0 sta $0
lda _gethex_resultptr+1 lda _gethex_resultptr+1
sta $1 sta $1
ldx #0 ;prep to copy back to result
lda _gethex_byteorder
beq :linearcopy
:byteordercopy ldx #0
lda _gethex_maxlen
lsr ;/2 ... took a looong time to find this bug
tay
dey ;we start at n-1 and work down to 0
:copyBufferBackwardsByte lda _gethex_buffer,x
asl ; move to upper nibble
asl
asl
asl
sta ($0),y ; store
inx
lda _gethex_buffer,x
ora ($0),y
sta ($0),y
dey
inx
cpx _gethex_maxlen
bcc :copyBufferBackwardsByte
rts
:linearcopy ldx #0
ldy #0 ldy #0
:copyBuffer lda _gethex_buffer,x :copyBuffer lda _gethex_buffer,x
asl ; move to upper nibble asl ; move to upper nibble
@ -626,7 +712,7 @@ GetHex
bcc :copyBuffer bcc :copyBuffer
rts rts
:badChar jmp :input
_gethex_internalmax equ 8 _gethex_internalmax equ 8
_gethex_resultptr da 0000 _gethex_resultptr da 0000
@ -634,6 +720,7 @@ _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
_gethex_byteorder db 0 ;0=linear, 1=6502 address byte order.. Least significant byte first.
*** INPUT LIBRARY FOR MENU *** INPUT LIBRARY FOR MENU
* Pass desired length in A * Pass desired length in A
@ -860,5 +947,3 @@ BINBCDVARDUMP
jsr RDKEY jsr RDKEY
rts rts

View File

@ -109,10 +109,18 @@ WaitSCB sta :val+1
; the problem is we can get the LAST ; the problem is we can get the LAST
; horizcnt even/odd right as it changes ; horizcnt even/odd right as it changes
; and start early or something? ; and start early or something?
rts rts
MAXSCB db 0 MAXSCB db 0
Full16 MAC
clc
xce
rep #$30
<<<
ShortMX MAC
sep #$30
<<<
PushAll MAC PushAll MAC
pha pha
@ -125,3 +133,5 @@ PopAll MAC
plx plx
pla pla
<<< <<<

View File

@ -158,7 +158,11 @@ TestInit
TestMasterLoop clc TestMasterLoop clc
xce xce
rep #$10 ;long x/y rep #$10 ;long x/y
ldy StartAddr
ldx EndAddr
stz CurBank stz CurBank
lda _updateInterval ;@todo ?
sta _updateTick ;this hack makes bank loops consistent. might not be the best thing
jsr TestPrintIteration jsr TestPrintIteration
jsr TestPrintErrors ;just to get it drawn jsr TestPrintErrors ;just to get it drawn
:NextBank jsr TestSetState ;sets read/write/both :NextBank jsr TestSetState ;sets read/write/both
@ -1231,11 +1235,11 @@ MainMenuDefs
db 01 ; memory size (bytes) db 01 ; memory size (bytes)
da EndBank ; variable storage da EndBank ; variable storage
:StartAddr hex 19,06 ; x,y :StartAddr hex 19,06 ; x,y
db Menu_TypeHex ; 1=hex input db Menu_TypeHexByteOrder ; 1=hex input
db 02 ; memory size (bytes) db 02 ; memory size (bytes)
da StartAddr ; variable storage da StartAddr ; variable storage
:EndAddr hex 20,06 ; x,y :EndAddr hex 20,06 ; x,y
db Menu_TypeHex ; 1=hex input db Menu_TypeHexByteOrder ; 1=hex input
db 02 ; memory size (bytes) db 02 ; memory size (bytes)
da EndAddr ; variable storage da EndAddr ; variable storage
:TestType hex 19,07 ; x,y :TestType hex 19,07 ; x,y
@ -1246,7 +1250,6 @@ MainMenuDefs
db Menu_TypeList ; 3=list input db Menu_TypeList ; 3=list input
db 6 ; max len size (bytes), 3=option list db 6 ; max len size (bytes), 3=option list
da TestSizeTbl ; params definition & storage da TestSizeTbl ; params definition & storage
:HexPattern hex 19,08 ; x,y :HexPattern hex 19,08 ; x,y
db Menu_TypeHex ; 3=list input db Menu_TypeHex ; 3=list input
_hexpatternsize db 02 ; max len size (bytes), 3=option list <- can change when 8 bit?? _hexpatternsize db 02 ; max len size (bytes), 3=option list <- can change when 8 bit??
@ -1302,8 +1305,10 @@ Menu_ItemSelected db 0
* ... also disable AdjacentWrite if TwoPass * ... also disable AdjacentWrite if TwoPass
MenuUpdateConfig lda TestSize16Bit MenuUpdateConfig lda TestSize16Bit
bne :is16bit bne :is16bit
:is8bit jmp MenuSet8Bit :is8bit jsr MenuFixMax8
:is16bit jmp MenuSet16Bit jmp MenuSet8Bit
:is16bit jsr MenuFixMax16
jmp MenuSet16Bit
MenuSet16Bit lda #2 MenuSet16Bit lda #2
bra MenuSetBits bra MenuSetBits
MenuSet8Bit jsr MenuClearPatterns ;clear leftover chars because strings are shorter now MenuSet8Bit jsr MenuClearPatterns ;clear leftover chars because strings are shorter now
@ -1322,12 +1327,29 @@ MenuSetBits sta _hexpatternsize
cmp _lastAdjacentWrite cmp _lastAdjacentWrite
beq :done beq :done
sta _lastAdjacentWrite sta _lastAdjacentWrite
stz TestTwoPass stz TestTwoPass
stz _lastTwoPass stz _lastTwoPass
:done rts :done rts
_lastTwoPass db 0 _lastTwoPass db 0
_lastAdjacentWrite db 0 _lastAdjacentWrite db 0
MenuFixMax16 Full16
lda EndAddr
cmp #$FFFF
bne :noneed
dec EndAddr
:noneed ShortMX
rts
MenuFixMax8 Full16
lda EndAddr
cmp #$FFFE
bne :noneed
inc EndAddr
:noneed ShortMX
rts
* hack to allow for smaller portion of screen to update * hack to allow for smaller portion of screen to update
MenuClearPatterns PRINTXY #$17;#$8;_clearstring MenuClearPatterns PRINTXY #$17;#$8;_clearstring
PRINTXY #$17;#$9;_clearstring PRINTXY #$17;#$9;_clearstring
@ -1540,3 +1562,4 @@ BankExpansionHighest ds 1
BankMap ds 256 ;page-align maps just to make them easier to see BankMap ds 256 ;page-align maps just to make them easier to see
_stash ds 256 _stash ds 256
ds \ ds \