Last active
          July 1, 2019 16:12 
        
      - 
      
- 
        Save JettMonstersGoBoom/e4c92e5f22d35cfb447c2b080aff34bb to your computer and use it in GitHub Desktop. 
    charpad display 6502 C64
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | ; display a charpad data set | |
| ; 64tass.exe --cbm-prg autorun.s -o auto.prg | |
| ; note using ? doesn't take any room in the output | |
| *=$10 | |
| source .word ? | |
| dest .word ? | |
| tempx .byte ? | |
| screenChars = $3400 ; the 40x25 buffer | |
| screenPixels = $3800 ; the pixel data for font or bitmap ($1000 or $9000 are always charrom) | |
| ; this segment set's up a small basic program to SYS *initialize* | |
| *=$0801 | |
| .word ss,2019 | |
| .null $9e,format("%d", initialize) | |
| ss .word 0 | |
| ; the magic | |
| initialize: | |
| ; select multi color mode | |
| lda #$d8 | |
| sta $d016 | |
| ; set up the color registers | |
| lda #$c | |
| sta $d021 | |
| lda #$f | |
| sta $d022 | |
| lda #$1 | |
| sta $d023 | |
| ; copy the attributes | |
| jsr copyAttributes | |
| ; Select VIC bank | |
| lda # ((screenChars ^ $ffff) >> 14) | |
| sta $dd00 | |
| ; Set VIC screen and font pointers | |
| lda # (((screenChars & $3fff) / $0400) << 4) + (((screenPixels & $3fff) / $0800) << 1) | |
| sta $d018 | |
| ; do nothing else | |
| loop | |
| jmp loop | |
| ; copy attributes to color ram | |
| ; map defines what attributes to use | |
| copyAttributes: | |
| lda #<map | |
| sta source | |
| lda #>map | |
| sta source+1 | |
| ; color ram | |
| lda #$d8 | |
| sta dest+1 | |
| lda #$00 | |
| sta dest | |
| ; set x and y to zero too | |
| tax | |
| tay | |
| outerloop: | |
| stx tempx | |
| innerloop: | |
| ; get char from map | |
| lda (source),y | |
| ; char id is now X | |
| tax | |
| ; get color value from attributes | |
| lda attributes,x | |
| sta (dest),y | |
| ; next value | |
| iny | |
| bne innerloop | |
| ; add 1 to the high byte of the source and dest | |
| inc source+1 | |
| inc dest+1 | |
| ; outer loop | |
| ldx tempx | |
| inx | |
| ; copy 4 pages of 256 bytes | |
| cpx #4 | |
| bne outerloop | |
| rts | |
| ; aligned | |
| *=$3300 | |
| attributes: .binary "attributes.bin" | |
| *=$3400 | |
| map: .binary "map.bin" | |
| *=$3800 | |
| .binary "charset.bin" | |
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment