Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .const COLOR_ADDRESS = $d800
- // change these zero-page addresses to your specifications :)
- .const addressPntr1 = $f0
- .const addressPntr2 = $f2
- .const addressPntr3 = $f4
- // change these to your specifications :)
- .const SCREEN0_ADDRESS = 1024
- .const TITLE_CHARSET = $4800
- .const SCREEN_WIDTH = 40
- .const SCREEN_HEIGHT = 25
- .macro drawLargeText(x,y,s) {
- .for (var i = 0; i < s.size(); i++) {
- lda #s.charAt(i)
- ldx #[x+i*8]
- ldy #y
- jsr drawBigChar
- }
- }
- .pseudocommand copy8 src : dst {
- lda src
- sta dst
- }
- .macro add16im(value,src,dst) {
- clc
- lda #<value
- adc src + 0
- sta dst + 0
- lda #>value
- adc src + 1
- sta dst + 1
- }
- screen0_row_lo:
- .for (var y = 0; y < SCREEN_HEIGHT; y++) {
- .byte <(SCREEN0_ADDRESS + y * SCREEN_WIDTH)
- }
- screen0_row_hi:
- .for (var y = 0; y < SCREEN_HEIGHT; y++) {
- .byte >(SCREEN0_ADDRESS + y * SCREEN_WIDTH)
- }
- color_row_lo:
- .for (var y = 0; y < SCREEN_HEIGHT; y++) {
- .byte <(COLOR_ADDRESS + y * SCREEN_WIDTH)
- }
- color_row_hi:
- .for (var y = 0; y < SCREEN_HEIGHT; y++) {
- .byte >(COLOR_ADDRESS + y * SCREEN_WIDTH)
- }
- .namespace c64color {
- .label BLACK = $0
- .label WHITE = $1
- .label RED = $2
- .label CYAN = $3
- .label PURPLE = $4
- .label GREEN = $5
- .label BLUE = $6
- .label YELLOW = $7
- .label ORANGE = $8
- .label BROWN = $9
- .label LIGHT_RED = $A //10
- .label DARK_GREY = $B //11
- .label GREY = $C //12
- .label LIGHT_GREEN = $D //13
- .label LIGHT_BLUE = $E //14
- .label LIGHT_GREY = $F //15
- }
- //----------------------------------------------------------------------------------
- // drawBigChar
- // input: a = character value to draw (screen code)
- // input: x,y = x,y location for character
- //----------------------------------------------------------------------------------
- drawBigChar: {
- // save char code
- pha
- // setup screen pointer
- :copy8 screen0_row_lo,y : addressPntr2 + 0
- :copy8 screen0_row_hi,y : addressPntr2 + 1
- // setup color pointer
- :copy8 color_row_lo,y : addressPntr3 + 0
- :copy8 color_row_hi,y : addressPntr3 + 1
- txa
- pha
- // add x to pointers
- clc
- adc addressPntr2 + 0
- sta addressPntr2 + 0
- pla
- clc
- adc addressPntr3 + 0
- sta addressPntr3 + 0
- pla
- // convert a reg to character address in memory
- sta addressPntr1 + 0
- lda #0
- sta addressPntr1 + 1
- // x 8
- asl addressPntr1 + 0
- rol addressPntr1 + 1
- asl addressPntr1 + 0
- rol addressPntr1 + 1
- asl addressPntr1 + 0
- rol addressPntr1 + 1
- :add16im(TITLE_CHARSET,addressPntr1,addressPntr1)
- // copy char data to buffer
- ldy #7
- !:
- lda (addressPntr1),y
- sta charData,y
- dey
- bpl !-
- ldx #0
- copyCharLine:
- // copy char row to screen
- ldy #0
- copyCharRow:
- rol charData,x
- bcc noPixel
- // pixel char
- lda #32+128
- sta (addressPntr2),y
- // pixel color
- lda charColor0,x
- sta (addressPntr3),y
- noPixel:
- iny
- cpy #8
- bne copyCharRow
- // next line
- :add16im(SCREEN_WIDTH,addressPntr2,addressPntr2)
- :add16im(SCREEN_WIDTH,addressPntr3,addressPntr3)
- inx
- cpx #8
- bne copyCharLine
- rts
- charData:
- .byte 0,0,0,0,0,0,0,0
- // change these to match your big char row colors!!
- charColor0: .byte c64color.WHITE
- charColor1: .byte c64color.WHITE
- charColor2: .byte c64color.WHITE
- charColor3: .byte c64color.YELLOW
- charColor4: .byte c64color.YELLOW
- charColor5: .byte c64color.ORANGE
- charColor6: .byte c64color.LIGHT_RED
- charColor7: .byte c64color.LIGHT_RED
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement