2019-06-23 09:26:11 +00:00
|
|
|
// Shows a font where each char contains the number of the char (00-ff)
|
2021-06-19 19:26:05 +00:00
|
|
|
/// @file
|
2021-06-19 20:11:26 +00:00
|
|
|
/// Commodore 64 Registers and Constants
|
2021-06-19 19:26:05 +00:00
|
|
|
/// @file
|
2021-06-19 20:11:26 +00:00
|
|
|
/// The MOS 6526 Complex Interface Adapter (CIA)
|
2021-06-19 20:28:44 +00:00
|
|
|
///
|
2021-06-19 19:26:05 +00:00
|
|
|
/// http://archive.6502.org/datasheets/mos_6526_cia_recreated.pdf
|
2020-12-21 07:57:41 +00:00
|
|
|
// Commodore 64 PRG executable file
|
|
|
|
.file [name="font-hex-show.prg", type="prg", segments="Program"]
|
|
|
|
.segmentdef Program [segments="Basic, Code, Data"]
|
|
|
|
.segmentdef Basic [start=$0801]
|
|
|
|
.segmentdef Code [start=$80d]
|
|
|
|
.segmentdef Data [startAfter="Code"]
|
|
|
|
.segment Basic
|
2019-06-22 19:13:22 +00:00
|
|
|
:BasicUpstart(main)
|
2021-06-20 10:45:52 +00:00
|
|
|
/// $D018 VIC-II base addresses
|
|
|
|
// @see #VICII_MEMORY
|
2019-06-22 19:13:22 +00:00
|
|
|
.label D018 = $d018
|
|
|
|
.label SCREEN = $400
|
|
|
|
.label CHARSET = $2000
|
2020-12-21 07:57:41 +00:00
|
|
|
.segment Code
|
2019-06-22 19:13:22 +00:00
|
|
|
main: {
|
|
|
|
.const toD0181_return = (>(SCREEN&$3fff)*4)|(>CHARSET)/4&$f
|
2020-02-23 08:44:36 +00:00
|
|
|
// *D018 = toD018(SCREEN, CHARSET)
|
2019-06-22 19:13:22 +00:00
|
|
|
lda #toD0181_return
|
|
|
|
sta D018
|
2020-02-23 08:44:36 +00:00
|
|
|
// init_font_hex(CHARSET)
|
2019-06-23 09:26:11 +00:00
|
|
|
jsr init_font_hex
|
|
|
|
ldx #0
|
|
|
|
// Show all chars on screen
|
2019-09-29 21:13:37 +00:00
|
|
|
__b1:
|
2020-02-23 08:44:36 +00:00
|
|
|
// SCREEN[c] = c
|
2019-06-23 09:26:11 +00:00
|
|
|
txa
|
|
|
|
sta SCREEN,x
|
2020-02-23 08:44:36 +00:00
|
|
|
// for (byte c: 0..255)
|
2019-06-23 09:26:11 +00:00
|
|
|
inx
|
|
|
|
cpx #0
|
2019-09-29 21:13:37 +00:00
|
|
|
bne __b1
|
2020-02-23 08:44:36 +00:00
|
|
|
// }
|
2019-06-23 09:26:11 +00:00
|
|
|
rts
|
|
|
|
}
|
|
|
|
// Make charset from proto chars
|
2021-08-10 15:48:55 +00:00
|
|
|
// void init_font_hex(__zp(5) char *charset)
|
2019-06-23 09:26:11 +00:00
|
|
|
init_font_hex: {
|
2019-09-29 21:13:37 +00:00
|
|
|
.label __0 = $b
|
2019-06-23 09:26:11 +00:00
|
|
|
.label idx = $a
|
|
|
|
.label proto_lo = 7
|
|
|
|
.label charset = 5
|
|
|
|
.label c1 = 9
|
|
|
|
.label proto_hi = 2
|
|
|
|
.label c = 4
|
2019-06-22 19:13:22 +00:00
|
|
|
lda #0
|
2019-08-07 19:00:19 +00:00
|
|
|
sta.z c
|
2019-06-22 19:13:22 +00:00
|
|
|
lda #<FONT_HEX_PROTO
|
2019-08-07 19:00:19 +00:00
|
|
|
sta.z proto_hi
|
2019-06-22 19:13:22 +00:00
|
|
|
lda #>FONT_HEX_PROTO
|
2019-08-07 19:00:19 +00:00
|
|
|
sta.z proto_hi+1
|
2019-06-23 09:26:11 +00:00
|
|
|
lda #<CHARSET
|
2019-08-07 19:00:19 +00:00
|
|
|
sta.z charset
|
2019-06-23 09:26:11 +00:00
|
|
|
lda #>CHARSET
|
2019-08-07 19:00:19 +00:00
|
|
|
sta.z charset+1
|
2019-09-29 21:13:37 +00:00
|
|
|
__b1:
|
2019-06-23 09:26:11 +00:00
|
|
|
lda #0
|
2019-08-07 19:00:19 +00:00
|
|
|
sta.z c1
|
2019-06-22 19:13:22 +00:00
|
|
|
lda #<FONT_HEX_PROTO
|
2019-08-07 19:00:19 +00:00
|
|
|
sta.z proto_lo
|
2019-06-22 19:13:22 +00:00
|
|
|
lda #>FONT_HEX_PROTO
|
2019-08-07 19:00:19 +00:00
|
|
|
sta.z proto_lo+1
|
2019-09-29 21:13:37 +00:00
|
|
|
__b2:
|
2020-02-23 08:44:36 +00:00
|
|
|
// charset[idx++] = 0
|
2019-06-23 09:26:11 +00:00
|
|
|
lda #0
|
|
|
|
tay
|
|
|
|
sta (charset),y
|
|
|
|
lda #1
|
2019-08-07 19:00:19 +00:00
|
|
|
sta.z idx
|
2019-06-23 09:26:11 +00:00
|
|
|
ldx #0
|
2019-09-29 21:13:37 +00:00
|
|
|
__b3:
|
2020-02-23 08:44:36 +00:00
|
|
|
// proto_hi[i]<<4
|
2019-06-23 09:26:11 +00:00
|
|
|
txa
|
|
|
|
tay
|
2019-06-22 19:13:22 +00:00
|
|
|
lda (proto_hi),y
|
|
|
|
asl
|
|
|
|
asl
|
|
|
|
asl
|
2019-06-23 09:26:11 +00:00
|
|
|
asl
|
2019-09-29 21:13:37 +00:00
|
|
|
sta.z __0
|
2020-02-23 08:44:36 +00:00
|
|
|
// proto_lo[i]<<1
|
2019-06-23 09:26:11 +00:00
|
|
|
txa
|
|
|
|
tay
|
|
|
|
lda (proto_lo),y
|
|
|
|
asl
|
2020-02-23 08:44:36 +00:00
|
|
|
// proto_hi[i]<<4 | proto_lo[i]<<1
|
2019-09-29 21:13:37 +00:00
|
|
|
ora.z __0
|
2020-02-23 08:44:36 +00:00
|
|
|
// charset[idx++] = proto_hi[i]<<4 | proto_lo[i]<<1
|
2019-08-07 19:00:19 +00:00
|
|
|
ldy.z idx
|
2019-06-22 19:13:22 +00:00
|
|
|
sta (charset),y
|
2020-02-23 08:44:36 +00:00
|
|
|
// charset[idx++] = proto_hi[i]<<4 | proto_lo[i]<<1;
|
2019-08-07 19:00:19 +00:00
|
|
|
inc.z idx
|
2020-02-23 08:44:36 +00:00
|
|
|
// for( byte i: 0..4)
|
2019-06-23 09:26:11 +00:00
|
|
|
inx
|
|
|
|
cpx #5
|
2019-09-29 21:13:37 +00:00
|
|
|
bne __b3
|
2020-02-23 08:44:36 +00:00
|
|
|
// charset[idx++] = 0
|
2019-06-22 19:13:22 +00:00
|
|
|
lda #0
|
2019-08-07 19:00:19 +00:00
|
|
|
ldy.z idx
|
2019-06-22 19:13:22 +00:00
|
|
|
sta (charset),y
|
2020-02-23 08:44:36 +00:00
|
|
|
// charset[idx++] = 0;
|
2019-06-23 09:26:11 +00:00
|
|
|
iny
|
2020-02-23 08:44:36 +00:00
|
|
|
// charset[idx++] = 0
|
2019-06-22 19:13:22 +00:00
|
|
|
sta (charset),y
|
2020-02-23 08:44:36 +00:00
|
|
|
// proto_lo += 5
|
2019-06-22 19:13:22 +00:00
|
|
|
lda #5
|
|
|
|
clc
|
2019-08-07 19:00:19 +00:00
|
|
|
adc.z proto_lo
|
|
|
|
sta.z proto_lo
|
2019-06-22 19:13:22 +00:00
|
|
|
bcc !+
|
2019-08-07 19:00:19 +00:00
|
|
|
inc.z proto_lo+1
|
2019-06-22 19:13:22 +00:00
|
|
|
!:
|
2020-02-23 08:44:36 +00:00
|
|
|
// charset += 8
|
2019-06-22 19:13:22 +00:00
|
|
|
lda #8
|
|
|
|
clc
|
2019-08-07 19:00:19 +00:00
|
|
|
adc.z charset
|
|
|
|
sta.z charset
|
2019-06-22 19:13:22 +00:00
|
|
|
bcc !+
|
2019-08-07 19:00:19 +00:00
|
|
|
inc.z charset+1
|
2019-06-22 19:13:22 +00:00
|
|
|
!:
|
2020-02-23 08:44:36 +00:00
|
|
|
// for( byte c: 0..15 )
|
2019-08-07 19:00:19 +00:00
|
|
|
inc.z c1
|
2019-06-23 09:26:11 +00:00
|
|
|
lda #$10
|
2019-08-07 19:00:19 +00:00
|
|
|
cmp.z c1
|
2019-09-29 21:13:37 +00:00
|
|
|
bne __b2
|
2020-02-23 08:44:36 +00:00
|
|
|
// proto_hi += 5
|
2019-06-22 19:13:22 +00:00
|
|
|
lda #5
|
|
|
|
clc
|
2019-08-07 19:00:19 +00:00
|
|
|
adc.z proto_hi
|
|
|
|
sta.z proto_hi
|
2019-06-22 19:13:22 +00:00
|
|
|
bcc !+
|
2019-08-07 19:00:19 +00:00
|
|
|
inc.z proto_hi+1
|
2019-06-22 19:13:22 +00:00
|
|
|
!:
|
2020-02-23 08:44:36 +00:00
|
|
|
// for( byte c: 0..15 )
|
2019-08-07 19:00:19 +00:00
|
|
|
inc.z c
|
2019-06-22 19:13:22 +00:00
|
|
|
lda #$10
|
2019-08-07 19:00:19 +00:00
|
|
|
cmp.z c
|
2019-09-29 21:13:37 +00:00
|
|
|
bne __b1
|
2020-02-23 08:44:36 +00:00
|
|
|
// }
|
2019-06-22 19:13:22 +00:00
|
|
|
rts
|
|
|
|
}
|
2020-12-21 07:57:41 +00:00
|
|
|
.segment Data
|
2019-06-23 09:26:11 +00:00
|
|
|
// Bit patterns for symbols 0-f (3x5 pixels) used in font hex
|
|
|
|
FONT_HEX_PROTO: .byte 2, 5, 5, 5, 2, 6, 2, 2, 2, 7, 6, 1, 2, 4, 7, 6, 1, 2, 1, 6, 5, 5, 7, 1, 1, 7, 4, 6, 1, 6, 3, 4, 6, 5, 2, 7, 1, 1, 1, 1, 2, 5, 2, 5, 2, 2, 5, 3, 1, 1, 2, 5, 7, 5, 5, 6, 5, 6, 5, 6, 2, 5, 4, 5, 2, 6, 5, 5, 5, 6, 7, 4, 6, 4, 7, 7, 4, 6, 4, 4
|