Post by huckle on Jul 26, 2006 16:06:03 GMT -5
Being a past amiga coder and having 32bit registers and comprehensive addressing modes,
i'm finding what should be simple tasks rather difficult in 6502. For example, how do you guys get
around the problem of only having 8 bit index registers?
For example, I have a text scroller routine, with an 8*8 bitmap font saved in a sequential 'vertical strip' (8*480) ASCII layout.
The C64 is in bitmap mode 320*200.
When i'm fetching the font data and when i'm scrolling the data I'm having to split the routine into 2 parts, for when the X-register rolls over, then the 2nd routine performs
the same task but starts 256 bytes in. Has anyone got any tips for a more elegant solution to this?
Section of code below:
----------------------
i'm finding what should be simple tasks rather difficult in 6502. For example, how do you guys get
around the problem of only having 8 bit index registers?
For example, I have a text scroller routine, with an 8*8 bitmap font saved in a sequential 'vertical strip' (8*480) ASCII layout.
The C64 is in bitmap mode 320*200.
When i'm fetching the font data and when i'm scrolling the data I'm having to split the routine into 2 parts, for when the X-register rolls over, then the 2nd routine performs
the same task but starts 256 bytes in. Has anyone got any tips for a more elegant solution to this?
Section of code below:
----------------------
scrtext
ldx scrollpos
lda scroll,x
cmp #$FF ; end of scroll?
bne go
lda #0 ; reset to start of scroller
sta scrollpos
jmp scrtext
go sec ; Subtract from ASCII code to get start of font
sbc #32
clc
rol ; Multiply *8 to get offset into font bitmap
rol ;
rol
bcs over ; Rollover? Go to +256 plot routine
tax
lda font,x
sta $2000+312 ; plot char
lda font+1,x
sta $2000+313
lda font+2,x
sta $2000+314
lda font+3,x
sta $2000+315
lda font+4,x
sta $2000+316
lda font+5,x
sta $2000+317
lda font+6,x
sta $2000+318
lda font+7,x
sta $2000+319
inc scrollpos
jmp ack
over tax
lda font+256,x
sta $2000+312 ; plot char
lda font+257,x
sta $2000+313
lda font+258,x
sta $2000+314
lda font+259,x
sta $2000+315
lda font+260,x
sta $2000+316
lda font+261,x
sta $2000+317
lda font+262,x
sta $2000+318
lda font+263,x
sta $2000+319
inc scrollpos
jmp ack