Last active
July 29, 2022 07:02
-
-
Save amenasse/a396eb14311317b26d81cbda5e79cf4c to your computer and use it in GitHub Desktop.
Loading data from CharPad Pro in Kick Assembler (https://subchristsoftware.itch.io/charpad-pro)
This file contains 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
.filenamespace background | |
// Render Background | |
.var background_data = LoadBinary("gfx/background.bin") | |
.var background_colors = LoadBinary("gfx/background-colors.bin") | |
.label color_memory = 55296 | |
.label screen_memory = 1024 | |
// Zero Page segment, don't include in prg | |
.segment ZP "Background" | |
char_position: .word 0 | |
color_position: .word 0 | |
background_pointer: .word 0 | |
.segment BACKGROUND "CODE" | |
draw: | |
ldx #0 | |
lda #<color_memory | |
sta color_position | |
lda #>color_memory | |
sta color_position+1 | |
lda #<screen_memory | |
sta char_position | |
lda #>screen_memory | |
sta char_position+1,X | |
lda #<background | |
sta background_pointer | |
lda #>background | |
sta background_pointer+1 | |
ldy #0 | |
!: | |
lda (background_pointer),Y | |
sta (char_position),Y | |
tax | |
lda charset_attrib_L1_data, X | |
sta (color_position),Y | |
iny | |
bne !- | |
// next page | |
inc char_position+1 | |
inc background_pointer+1 | |
inc color_position+1 | |
lda char_position+1 | |
// End of screen high byte will be 8 | |
cmp #8 | |
bne !- | |
rts | |
.segment BACKGROUND "Background" | |
// Background and Color data imported from Charpad | |
.align $100 | |
background: | |
.fill background_data.getSize(), background_data.get(i) | |
// CHARSET IMAGE ATTRIBUTE DATA (L1)... | |
// 256 attributes, 1 attribute per image, 8 bits per attribute, total size is 256 ($100) bytes. | |
// nb. Upper nybbles = material (unused here), lower nybbles = colour (colour matrix low). | |
charset_attrib_L1_data: | |
.fill background_colors.getSize(), background_colors.get(i) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment