1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2024-10-21 02:24:34 +00:00
kickc/src/test/ref/c64dtv-gfxmodes.asm

2331 lines
43 KiB
NASM
Raw Normal View History

2019-02-17 23:12:29 +00:00
// Exploring C64DTV Screen Modes
2018-03-25 21:40:38 +00:00
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
2019-02-17 23:12:29 +00:00
// Processor port data direction register
.label PROCPORT_DDR = 0
2019-02-17 23:12:29 +00:00
// Mask for PROCESSOR_PORT_DDR which allows only memory configuration to be written
.const PROCPORT_DDR_MEMORY_MASK = 7
2019-02-17 23:12:29 +00:00
// Processor Port Register controlling RAM/ROM configuration and the datasette
2018-03-27 20:32:06 +00:00
.label PROCPORT = 1
2019-02-17 23:12:29 +00:00
// RAM in $A000, $E000 I/O in $D000
.const PROCPORT_RAM_IO = $35
2019-02-17 23:12:29 +00:00
// RAM in $A000, $E000 CHAR ROM in $D000
.const PROCPORT_RAM_CHARROM = $31
.label RASTER = $d012
2018-03-25 21:40:38 +00:00
.label BORDERCOL = $d020
.label BGCOL = $d021
.label BGCOL1 = $d021
.label BGCOL2 = $d022
.label BGCOL3 = $d023
.label BGCOL4 = $d024
2018-03-26 19:41:09 +00:00
.label VIC_CONTROL = $d011
2018-03-25 21:40:38 +00:00
.const VIC_ECM = $40
.const VIC_BMM = $20
.const VIC_DEN = $10
.const VIC_RSEL = 8
2018-03-26 19:41:09 +00:00
.label VIC_CONTROL2 = $d016
2018-03-27 08:01:28 +00:00
.const VIC_MCM = $10
2018-03-25 21:40:38 +00:00
.const VIC_CSEL = 8
2018-03-26 19:41:09 +00:00
.label VIC_MEMORY = $d018
2019-02-17 23:12:29 +00:00
// Color Ram
2018-03-25 21:40:38 +00:00
.label COLS = $d800
2019-02-17 23:12:29 +00:00
// CIA#1 Port A: keyboard matrix columns and joystick #2
2018-03-25 21:40:38 +00:00
.label CIA1_PORT_A = $dc00
2019-02-17 23:12:29 +00:00
// CIA#1 Port B: keyboard matrix rows and joystick #1.
2018-03-25 21:40:38 +00:00
.label CIA1_PORT_B = $dc01
2019-02-17 23:12:29 +00:00
// CIA#2 Port A: Serial bus, RS-232, VIC memory bank
2018-03-25 21:40:38 +00:00
.label CIA2_PORT_A = $dd00
2019-02-17 23:12:29 +00:00
// CIA #2 Port A data direction register.
2018-03-25 21:40:38 +00:00
.label CIA2_PORT_A_DDR = $dd02
2019-02-17 23:12:29 +00:00
// The colors of the C64
2018-03-29 06:49:51 +00:00
.const BLACK = 0
.const GREEN = 5
.const BLUE = 6
2018-03-25 21:40:38 +00:00
.const LIGHT_GREEN = $d
2019-02-17 23:12:29 +00:00
// Feature enables or disables the extra C64 DTV features
2018-03-25 21:40:38 +00:00
.label DTV_FEATURE = $d03f
.const DTV_FEATURE_ENABLE = 1
2019-02-17 23:12:29 +00:00
// Controls the graphics modes of the C64 DTV
2018-03-25 21:40:38 +00:00
.label DTV_CONTROL = $d03c
.const DTV_LINEAR = 1
.const DTV_BORDER_OFF = 2
.const DTV_HIGHCOLOR = 4
.const DTV_OVERSCAN = 8
.const DTV_COLORRAM_OFF = $10
.const DTV_CHUNKY = $40
2019-02-17 23:12:29 +00:00
// Defines colors for the 16 first colors ($00-$0f)
.label DTV_PALETTE = $d200
2019-02-17 23:12:29 +00:00
// Linear Graphics Plane A Counter Control
2018-03-25 21:40:38 +00:00
.label DTV_PLANEA_START_LO = $d03a
.label DTV_PLANEA_START_MI = $d03b
.label DTV_PLANEA_START_HI = $d045
.label DTV_PLANEA_STEP = $d046
.label DTV_PLANEA_MODULO_LO = $d038
.label DTV_PLANEA_MODULO_HI = $d039
2019-02-17 23:12:29 +00:00
// Linear Graphics Plane B Counter Control
2018-03-25 21:40:38 +00:00
.label DTV_PLANEB_START_LO = $d049
.label DTV_PLANEB_START_MI = $d04a
.label DTV_PLANEB_START_HI = $d04b
.label DTV_PLANEB_STEP = $d04c
.label DTV_PLANEB_MODULO_LO = $d047
.label DTV_PLANEB_MODULO_HI = $d048
2019-02-17 23:12:29 +00:00
// Select memory bank where color data is fetched from (bits 11:0)
// Memory address of Color RAM is ColorBank*$400
.label DTV_COLOR_BANK_LO = $d036
.label DTV_COLOR_BANK_HI = $d037
.const DTV_COLOR_BANK_DEFAULT = $1d800
2019-02-17 23:12:29 +00:00
// Selects memory bank for normal VIC color mode and lower data for high color modes. (bits 5:0)
// Memory address of VIC Graphics is GraphicsBank*$10000
2018-03-25 21:40:38 +00:00
.label DTV_GRAPHICS_VIC_BANK = $d03d
2018-03-29 06:49:51 +00:00
.const KEY_3 = 8
2018-03-28 14:43:47 +00:00
.const KEY_A = $a
.const KEY_4 = $b
2018-03-28 11:00:32 +00:00
.const KEY_E = $e
2018-03-27 20:32:06 +00:00
.const KEY_D = $12
.const KEY_6 = $13
2018-03-25 21:40:38 +00:00
.const KEY_C = $14
2018-03-29 06:49:51 +00:00
.const KEY_7 = $18
2018-03-29 07:09:07 +00:00
.const KEY_8 = $1b
2018-03-27 08:01:28 +00:00
.const KEY_B = $1c
.const KEY_H = $1d
.const KEY_U = $1e
.const KEY_0 = $23
.const KEY_O = $26
.const KEY_L = $2a
.const KEY_1 = $38
.const KEY_2 = $3b
2018-03-25 21:40:38 +00:00
.const KEY_SPACE = $3c
2018-03-28 11:00:32 +00:00
.label print_char_cursor = 5
.label dtv_control = 4
.label print_line_cursor = $d
2018-03-25 21:40:38 +00:00
main: {
sei
2019-02-17 23:12:29 +00:00
// Disable normal interrupt (prevent keyboard reading glitches and allows to hide basic/kernal)
// Disable kernal & basic
lda #PROCPORT_DDR_MEMORY_MASK
sta PROCPORT_DDR
lda #PROCPORT_RAM_IO
sta PROCPORT
2019-02-17 23:12:29 +00:00
// Enable DTV extended modes
2018-03-25 21:40:38 +00:00
lda #DTV_FEATURE_ENABLE
sta DTV_FEATURE
b2:
jsr menu
jmp b2
}
menu: {
2018-03-29 07:09:07 +00:00
.label SCREEN = $8000
.label CHARSET = $9800
.label c = 2
2019-02-17 23:12:29 +00:00
// Charset ROM
// DTV Graphics Bank
2018-03-29 07:09:07 +00:00
lda #($ffffffff&CHARSET)/$10000
2018-03-25 21:40:38 +00:00
sta DTV_GRAPHICS_VIC_BANK
2019-02-17 23:12:29 +00:00
// DTV Color Bank
lda #DTV_COLOR_BANK_DEFAULT/$400
sta DTV_COLOR_BANK_LO
2018-03-25 21:40:38 +00:00
lda #0
sta DTV_COLOR_BANK_HI
2019-02-17 23:12:29 +00:00
// DTV Graphics Mode
2018-03-25 21:40:38 +00:00
sta DTV_CONTROL
2019-02-17 23:12:29 +00:00
// VIC Graphics Bank
2018-03-25 21:40:38 +00:00
lda #3
sta CIA2_PORT_A_DDR
2019-02-17 23:12:29 +00:00
// Set VIC Bank bits to output - all others to input
2018-03-29 07:09:07 +00:00
lda #3^CHARSET/$4000
2018-03-25 21:40:38 +00:00
sta CIA2_PORT_A
2019-02-17 23:12:29 +00:00
// Set VIC Bank
// VIC Graphics Mode
2018-03-25 21:40:38 +00:00
lda #VIC_DEN|VIC_RSEL|3
2018-03-26 19:41:09 +00:00
sta VIC_CONTROL
2018-03-25 21:40:38 +00:00
lda #VIC_CSEL
2018-03-26 19:41:09 +00:00
sta VIC_CONTROL2
2019-02-17 23:12:29 +00:00
// VIC Memory Pointers
2018-03-29 07:09:07 +00:00
lda #(SCREEN&$3fff)/$40|(CHARSET&$3fff)/$400
2018-03-26 19:41:09 +00:00
sta VIC_MEMORY
2018-04-01 10:32:45 +00:00
ldx #0
2019-02-17 23:12:29 +00:00
// DTV Palette - default
b1:
2018-04-01 10:32:45 +00:00
lda DTV_PALETTE_DEFAULT,x
sta DTV_PALETTE,x
inx
cpx #$10
bne b1
2018-03-25 21:40:38 +00:00
lda #<COLS
sta c
lda #>COLS
sta c+1
2019-02-17 23:12:29 +00:00
// Char Colors
b2:
2018-03-25 21:40:38 +00:00
lda #LIGHT_GREEN
ldy #0
sta (c),y
inc c
bne !+
inc c+1
!:
lda c+1
cmp #>COLS+$3e8
bne b2
2018-03-25 21:40:38 +00:00
lda c
cmp #<COLS+$3e8
bne b2
2019-02-17 23:12:29 +00:00
// Screen colors
2018-03-25 21:40:38 +00:00
lda #0
sta BGCOL
sta BORDERCOL
jsr print_set_screen
jsr print_cls
2018-03-26 19:41:09 +00:00
jsr print_str_lines
b4:
ldy #KEY_1
2018-03-25 21:40:38 +00:00
jsr keyboard_key_pressed
cmp #0
2018-03-27 08:01:28 +00:00
beq b6
jsr mode_stdchar
breturn:
rts
2018-03-27 08:01:28 +00:00
b6:
ldy #KEY_2
2018-03-27 08:01:28 +00:00
jsr keyboard_key_pressed
cmp #0
2018-03-27 20:32:06 +00:00
beq b7
jsr mode_ecmchar
2018-03-27 08:01:28 +00:00
jmp breturn
2018-03-27 20:32:06 +00:00
b7:
ldy #KEY_3
2018-03-27 20:32:06 +00:00
jsr keyboard_key_pressed
cmp #0
2018-03-28 11:00:32 +00:00
beq b8
2018-03-29 07:09:07 +00:00
jsr mode_mcchar
2018-03-27 20:32:06 +00:00
jmp breturn
2018-03-28 11:00:32 +00:00
b8:
ldy #KEY_4
2018-03-28 14:43:47 +00:00
jsr keyboard_key_pressed
cmp #0
beq b9
jsr mode_stdbitmap
2018-03-28 14:43:47 +00:00
jmp breturn
b9:
ldy #KEY_6
jsr keyboard_key_pressed
cmp #0
beq b10
jsr mode_hicolstdchar
jmp breturn
b10:
ldy #KEY_7
jsr keyboard_key_pressed
cmp #0
beq b11
jsr mode_hicolecmchar
jmp breturn
b11:
ldy #KEY_8
jsr keyboard_key_pressed
cmp #0
beq b12
jsr mode_hicolmcchar
jmp breturn
b12:
ldy #KEY_A
2018-03-29 06:49:51 +00:00
jsr keyboard_key_pressed
cmp #0
beq b13
jsr mode_sixsfred2
2018-03-29 06:49:51 +00:00
jmp breturn
b13:
ldy #KEY_B
2018-03-29 06:49:51 +00:00
jsr keyboard_key_pressed
cmp #0
beq b14
jsr mode_twoplanebitmap
2018-03-29 06:49:51 +00:00
jmp breturn
b14:
ldy #KEY_C
2018-03-29 07:09:07 +00:00
jsr keyboard_key_pressed
cmp #0
beq b15
jsr mode_sixsfred
2018-03-29 07:09:07 +00:00
jmp breturn
b15:
ldy #KEY_D
jsr keyboard_key_pressed
cmp #0
beq b16
jsr mode_8bpppixelcell
jmp breturn
b16:
ldy #KEY_E
2018-03-28 11:00:32 +00:00
jsr keyboard_key_pressed
cmp #0
2018-03-29 06:49:51 +00:00
bne !b4+
jmp b4
!b4:
2018-03-28 11:00:32 +00:00
jsr mode_8bppchunkybmm
jmp breturn
}
2019-02-17 23:12:29 +00:00
//Chunky 8bpp Bitmap Mode (BMM = 0, ECM/MCM/HICOL/LINEAR/CHUNK/COLDIS = 1)
// Resolution: 320x200
// Linear Adressing
// CharData/PlaneB Pixel Shifter (8):
// - 8bpp color PlaneB[7:0]
// To set up a linear video frame buffer the step size must be set to 8.
2018-03-28 11:00:32 +00:00
mode_8bppchunkybmm: {
2019-02-17 23:12:29 +00:00
// 8BPP Chunky Bitmap (contains 8bpp pixels)
2018-03-29 07:09:07 +00:00
.const PLANEB = $20000
.label _23 = $d
2018-03-28 11:00:32 +00:00
.label gfxb = 5
.label x = 2
.label y = 4
lda #DTV_HIGHCOLOR|DTV_LINEAR|DTV_CHUNKY|DTV_COLORRAM_OFF
2018-03-28 11:00:32 +00:00
sta DTV_CONTROL
2019-02-17 23:12:29 +00:00
// VIC Graphics Mode
2018-03-28 11:00:32 +00:00
lda #VIC_ECM|VIC_DEN|VIC_RSEL|3
sta VIC_CONTROL
lda #VIC_MCM|VIC_CSEL
sta VIC_CONTROL2
2019-02-17 23:12:29 +00:00
// Linear Graphics Plane B Counter
2018-03-29 07:09:07 +00:00
lda #PLANEB&$ffff
2018-03-28 11:00:32 +00:00
sta DTV_PLANEB_START_LO
lda #0
sta DTV_PLANEB_START_MI
2018-03-29 07:09:07 +00:00
lda #PLANEB>>$10
2018-03-28 11:00:32 +00:00
sta DTV_PLANEB_START_HI
lda #8
sta DTV_PLANEB_STEP
lda #0
sta DTV_PLANEB_MODULO_LO
sta DTV_PLANEB_MODULO_HI
2019-02-17 23:12:29 +00:00
// Border color
2018-03-28 11:00:32 +00:00
sta BORDERCOL
tax
2019-02-17 23:12:29 +00:00
// DTV Palette - Grey Tones
2018-03-28 11:00:32 +00:00
b1:
txa
sta DTV_PALETTE,x
inx
cpx #$10
bne b1
2018-03-29 07:09:07 +00:00
lda #PLANEB/$4000
2018-03-28 11:00:32 +00:00
jsr dtvSetCpuBankSegment1
2018-03-29 07:09:07 +00:00
ldx #PLANEB/$4000+1
2018-03-28 11:00:32 +00:00
lda #0
sta y
lda #<$4000
sta gfxb
lda #>$4000
sta gfxb+1
b2:
lda #<0
sta x
sta x+1
b3:
lda gfxb+1
cmp #>$8000
bne b4
lda gfxb
cmp #<$8000
bne b4
txa
jsr dtvSetCpuBankSegment1
inx
lda #<$4000
sta gfxb
lda #>$4000
sta gfxb+1
b4:
lda y
clc
adc x
sta _23
2018-03-28 11:00:32 +00:00
lda #0
adc x+1
sta _23+1
lda _23
2018-03-28 11:00:32 +00:00
ldy #0
sta (gfxb),y
inc gfxb
bne !+
inc gfxb+1
!:
inc x
bne !+
inc x+1
!:
lda x+1
cmp #>$140
bne b3
lda x
cmp #<$140
bne b3
inc y
lda y
cmp #$c8
bne b2
lda #$4000/$4000
jsr dtvSetCpuBankSegment1
2018-04-01 10:32:45 +00:00
lda #DTV_HIGHCOLOR|DTV_LINEAR|DTV_CHUNKY|DTV_COLORRAM_OFF
sta dtv_control
jsr mode_ctrl
rts
}
2019-02-17 23:12:29 +00:00
// Allow the user to control the DTV graphics using different keys
mode_ctrl: {
2019-02-17 16:53:19 +00:00
b1:
2019-02-17 23:12:29 +00:00
// Wait for the raster
b4:
lda RASTER
cmp #$ff
bne b4
ldy #KEY_SPACE
jsr keyboard_key_pressed
cmp #0
beq b7
rts
b7:
2019-02-17 23:12:29 +00:00
// Read the current control byte
2018-04-01 10:32:45 +00:00
ldx dtv_control
ldy #KEY_L
jsr keyboard_key_pressed
cmp #0
2018-04-01 10:32:45 +00:00
beq b8
txa
ora #DTV_LINEAR
tax
b8:
ldy #KEY_H
jsr keyboard_key_pressed
cmp #0
2018-04-01 10:32:45 +00:00
beq b9
txa
ora #DTV_HIGHCOLOR
tax
b9:
ldy #KEY_O
jsr keyboard_key_pressed
cmp #0
2018-04-01 10:32:45 +00:00
beq b10
txa
ora #DTV_OVERSCAN
tax
b10:
ldy #KEY_B
2018-03-28 11:00:32 +00:00
jsr keyboard_key_pressed
cmp #0
2018-04-01 10:32:45 +00:00
beq b11
txa
ora #DTV_BORDER_OFF
tax
b11:
ldy #KEY_U
jsr keyboard_key_pressed
cmp #0
2018-04-01 10:32:45 +00:00
beq b12
txa
ora #DTV_CHUNKY
tax
b12:
ldy #KEY_C
jsr keyboard_key_pressed
cmp #0
2018-04-01 10:32:45 +00:00
beq b13
txa
ora #DTV_COLORRAM_OFF
tax
b13:
ldy #KEY_0
jsr keyboard_key_pressed
cmp #0
2018-04-01 10:32:45 +00:00
beq b14
ldx #0
b14:
cpx dtv_control
2019-02-17 16:53:19 +00:00
beq b1
2018-04-01 10:32:45 +00:00
stx dtv_control
stx DTV_CONTROL
stx BORDERCOL
2019-02-17 16:53:19 +00:00
jmp b1
2018-03-28 11:00:32 +00:00
}
2019-02-17 23:12:29 +00:00
// Determines whether a specific key is currently pressed by accessing the matrix directly
// The key is a keyboard code defined from the keyboard matrix by %00rrrccc, where rrr is the row ID (0-7) and ccc is the column ID (0-7)
// All keys exist as as KEY_XXX constants.
// Returns zero if the key is not pressed and a non-zero value if the key is currently pressed
2018-03-28 11:00:32 +00:00
keyboard_key_pressed: {
.label colidx = 7
tya
2018-03-28 11:00:32 +00:00
and #7
sta colidx
tya
2018-03-28 11:00:32 +00:00
lsr
lsr
lsr
tay
2018-03-28 11:00:32 +00:00
jsr keyboard_matrix_read
ldy colidx
2018-03-28 11:00:32 +00:00
and keyboard_matrix_col_bitmask,y
rts
}
2019-02-17 23:12:29 +00:00
// Read a single row of the keyboard matrix
// The row ID (0-7) of the keyboard matrix row to read. See the C64 key matrix for row IDs.
// Returns the keys pressed on the row as bits according to the C64 key matrix.
// Notice: If the C64 normal interrupt is still running it will occasionally interrupt right between the read & write
// leading to erroneous readings. You must disable kill the normal interrupt or sei/cli around calls to the keyboard matrix reader.
2018-03-28 11:00:32 +00:00
keyboard_matrix_read: {
lda keyboard_matrix_row_bitmask,y
2018-03-28 11:00:32 +00:00
sta CIA1_PORT_A
lda CIA1_PORT_B
eor #$ff
rts
}
2019-02-17 23:12:29 +00:00
// Set the memory pointed to by CPU BANK 1 SEGMENT ($4000-$7fff)
// This sets which actual memory is addressed when the CPU reads/writes to $4000-$7fff
// The actual memory addressed will be $4000*cpuSegmentIdx
2018-03-28 11:00:32 +00:00
dtvSetCpuBankSegment1: {
2019-02-17 23:12:29 +00:00
// Move CPU BANK 1 SEGMENT ($4000-$7fff)
2018-03-28 11:00:32 +00:00
.label cpuBank = $ff
sta cpuBank
.byte $32, $dd
lda $ff
.byte $32, $00
rts
2018-03-27 20:32:06 +00:00
}
2019-02-17 23:12:29 +00:00
//8bpp Pixel Cell Mode (BMM/COLDIS = 0, ECM/MCM/HICOL/LINEAR/CHUNK = 1)
//Pixel Cell Adressing
//CharData[8]: (PlaneA[21:0])
//GfxData[8]: (PlaneB[21:14] & CharData[7:0] & RowCounter[3:0] & PixelCounter[7:0] )
//GfxData Pixel Shifter (8):
//- 8bpp color GfxData[7:0]
//Pixel cell mode can be thought of as a text mode that uses a 8x8 pixel 8bpp font (64 bytes/char).
//The characters come from counter A and the font (or "cells") from counter B.
//Counter B step and modulo should be set to 0, counter A modulo to 0 and counter A step to 1 for normal operation.
2018-03-27 20:32:06 +00:00
mode_8bpppixelcell: {
2019-02-17 23:12:29 +00:00
// 8BPP Pixel Cell Screen (contains 40x25=1000 chars)
2018-03-29 07:09:07 +00:00
.label PLANEA = $3c00
2019-02-17 23:12:29 +00:00
// 8BPP Pixel Cell Charset (contains 256 64 byte chars)
2018-03-29 07:09:07 +00:00
.label PLANEB = $4000
.label _14 = 7
.label gfxa = 2
.label ay = 4
2018-03-28 11:00:32 +00:00
.label bits = 8
.label chargen = 2
2018-03-28 11:00:32 +00:00
.label gfxb = 5
2018-03-27 20:32:06 +00:00
.label col = 9
2018-03-28 11:00:32 +00:00
.label cr = 7
.label ch = 4
lda #DTV_HIGHCOLOR|DTV_LINEAR|DTV_CHUNKY
2018-03-27 20:32:06 +00:00
sta DTV_CONTROL
2019-02-17 23:12:29 +00:00
// VIC Graphics Mode
2018-03-27 20:32:06 +00:00
lda #VIC_ECM|VIC_DEN|VIC_RSEL|3
sta VIC_CONTROL
lda #VIC_MCM|VIC_CSEL
sta VIC_CONTROL2
2019-02-17 23:12:29 +00:00
// Linear Graphics Plane A Counter
2018-03-29 07:09:07 +00:00
lda #<PLANEA
2018-03-27 20:32:06 +00:00
sta DTV_PLANEA_START_LO
2018-03-29 07:09:07 +00:00
lda #>PLANEA
2018-03-27 20:32:06 +00:00
sta DTV_PLANEA_START_MI
lda #0
sta DTV_PLANEA_START_HI
lda #1
sta DTV_PLANEA_STEP
lda #0
sta DTV_PLANEA_MODULO_LO
sta DTV_PLANEA_MODULO_HI
2019-02-17 23:12:29 +00:00
// Linear Graphics Plane B Counter
2018-03-29 07:09:07 +00:00
lda #<PLANEB
2018-03-27 20:32:06 +00:00
sta DTV_PLANEB_START_LO
2018-03-29 07:09:07 +00:00
lda #>PLANEB
2018-03-27 20:32:06 +00:00
sta DTV_PLANEB_START_MI
lda #0
sta DTV_PLANEB_START_HI
sta DTV_PLANEB_STEP
sta DTV_PLANEB_MODULO_LO
sta DTV_PLANEB_MODULO_HI
2019-02-17 23:12:29 +00:00
// Border color
2018-03-27 20:32:06 +00:00
sta BORDERCOL
tax
2019-02-17 23:12:29 +00:00
// DTV Palette - Grey Tones
2018-03-27 20:32:06 +00:00
b1:
txa
sta DTV_PALETTE,x
inx
cpx #$10
bne b1
2018-03-29 07:09:07 +00:00
lda #<PLANEA
2018-03-27 20:32:06 +00:00
sta gfxa
2018-03-29 07:09:07 +00:00
lda #>PLANEA
2018-03-27 20:32:06 +00:00
sta gfxa+1
lda #0
sta ay
b2:
ldx #0
b3:
lda #$f
and ay
asl
asl
asl
asl
sta _14
2018-03-27 20:32:06 +00:00
txa
and #$f
ora _14
2018-03-27 20:32:06 +00:00
ldy #0
sta (gfxa),y
inc gfxa
bne !+
inc gfxa+1
!:
inx
cpx #$28
bne b3
inc ay
lda ay
cmp #$19
bne b2
2019-02-17 23:12:29 +00:00
// 8bpp cells for Plane B (charset) - ROM charset with 256 colors
lda #PROCPORT_RAM_CHARROM
2018-03-27 20:32:06 +00:00
sta PROCPORT
lda #0
sta ch
sta col
2018-03-29 07:09:07 +00:00
lda #<PLANEB
2018-03-27 20:32:06 +00:00
sta gfxb
2018-03-29 07:09:07 +00:00
lda #>PLANEB
2018-03-27 20:32:06 +00:00
sta gfxb+1
lda #<$d000
sta chargen
lda #>$d000
sta chargen+1
b4:
lda #0
sta cr
b5:
ldy #0
lda (chargen),y
sta bits
inc chargen
bne !+
inc chargen+1
!:
ldx #0
b6:
lda #$80
and bits
cmp #0
beq b8
2018-03-27 20:32:06 +00:00
lda col
jmp b7
b8:
2018-03-27 20:32:06 +00:00
lda #0
b7:
ldy #0
sta (gfxb),y
inc gfxb
bne !+
inc gfxb+1
!:
asl bits
inc col
inx
cpx #8
bne b6
inc cr
lda cr
cmp #8
bne b5
inc ch
lda ch
2018-12-18 23:33:27 +00:00
cmp #0
2018-03-27 20:32:06 +00:00
bne b4
lda #PROCPORT_RAM_IO
2018-03-27 20:32:06 +00:00
sta PROCPORT
2018-04-01 10:32:45 +00:00
lda #DTV_HIGHCOLOR|DTV_LINEAR|DTV_CHUNKY
sta dtv_control
jsr mode_ctrl
2018-03-27 20:32:06 +00:00
rts
}
2019-02-17 23:12:29 +00:00
// Sixs Fred Mode - 8bpp Packed Bitmap - Generated from the two DTV linear graphics plane counters
// Two Plane MultiColor Bitmap - 8bpp Packed Bitmap (CHUNK/COLDIS = 0, ECM/BMM/MCM/HICOL/LINEAR = 1)
// Resolution: 160x200
// Linear Adressing
// GfxData/PlaneA Pixel Shifter (2), CharData/PlaneB Pixel Shifter (2):
// - 8bpp color (ColorData[3:0],CharData/PlaneB[1:0], GfxData/PlaneA[1:0])
2018-03-27 08:01:28 +00:00
mode_sixsfred: {
2018-03-29 07:09:07 +00:00
.label PLANEA = $4000
.label PLANEB = $6000
.label COLORS = $8000
.label col = 2
.label cy = 4
.label gfxa = 2
.label ay = 4
.label gfxb = 2
.label by = 4
lda #DTV_HIGHCOLOR|DTV_LINEAR
2018-03-27 08:01:28 +00:00
sta DTV_CONTROL
2019-02-17 23:12:29 +00:00
// VIC Graphics Mode
2018-03-27 08:01:28 +00:00
lda #VIC_ECM|VIC_BMM|VIC_DEN|VIC_RSEL|3
sta VIC_CONTROL
lda #VIC_MCM|VIC_CSEL
sta VIC_CONTROL2
2019-02-17 23:12:29 +00:00
// Linear Graphics Plane A Counter
2018-03-29 07:09:07 +00:00
lda #<PLANEA
2018-03-27 08:01:28 +00:00
sta DTV_PLANEA_START_LO
2018-03-29 07:09:07 +00:00
lda #>PLANEA
2018-03-27 08:01:28 +00:00
sta DTV_PLANEA_START_MI
lda #0
sta DTV_PLANEA_START_HI
lda #1
sta DTV_PLANEA_STEP
lda #0
sta DTV_PLANEA_MODULO_LO
sta DTV_PLANEA_MODULO_HI
2019-02-17 23:12:29 +00:00
// Linear Graphics Plane B Counter
2018-03-29 07:09:07 +00:00
lda #<PLANEB
2018-03-27 08:01:28 +00:00
sta DTV_PLANEB_START_LO
2018-03-29 07:09:07 +00:00
lda #>PLANEB
2018-03-27 08:01:28 +00:00
sta DTV_PLANEB_START_MI
lda #0
sta DTV_PLANEB_START_HI
lda #1
sta DTV_PLANEB_STEP
lda #0
sta DTV_PLANEB_MODULO_LO
sta DTV_PLANEB_MODULO_HI
2019-02-17 23:12:29 +00:00
// DTV Color Bank
2018-03-29 07:09:07 +00:00
lda #<COLORS/$400
2018-03-27 08:01:28 +00:00
sta DTV_COLOR_BANK_LO
2018-03-29 07:09:07 +00:00
lda #>COLORS/$400
2018-03-27 08:01:28 +00:00
sta DTV_COLOR_BANK_HI
ldx #0
2019-02-17 23:12:29 +00:00
// DTV Palette - Grey Tones
2018-03-27 08:01:28 +00:00
b1:
txa
sta DTV_PALETTE,x
inx
cpx #$10
bne b1
2019-02-17 23:12:29 +00:00
// Screen colors
2018-03-27 08:01:28 +00:00
lda #0
sta BORDERCOL
2018-03-29 07:09:07 +00:00
lda #<COLORS
2018-03-27 08:01:28 +00:00
sta col
2018-03-29 07:09:07 +00:00
lda #>COLORS
2018-03-27 08:01:28 +00:00
sta col+1
lda #0
sta cy
b2:
ldx #0
b3:
txa
clc
adc cy
and #$f
ldy #0
sta (col),y
inc col
bne !+
inc col+1
!:
inx
cpx #$28
bne b3
inc cy
lda cy
cmp #$19
bne b2
2018-03-29 07:09:07 +00:00
lda #<PLANEA
2018-03-27 08:01:28 +00:00
sta gfxa
2018-03-29 07:09:07 +00:00
lda #>PLANEA
2018-03-27 08:01:28 +00:00
sta gfxa+1
lda #0
sta ay
b4:
ldx #0
b5:
lda ay
lsr
and #3
tay
lda row_bitmask,y
ldy #0
sta (gfxa),y
inc gfxa
bne !+
inc gfxa+1
!:
inx
cpx #$28
bne b5
inc ay
lda ay
cmp #$c8
bne b4
lda #0
sta by
2018-03-29 07:09:07 +00:00
lda #<PLANEB
2018-03-27 08:01:28 +00:00
sta gfxb
2018-03-29 07:09:07 +00:00
lda #>PLANEB
2018-03-27 08:01:28 +00:00
sta gfxb+1
b6:
ldx #0
b7:
lda #$1b
ldy #0
sta (gfxb),y
inc gfxb
bne !+
inc gfxb+1
!:
inx
cpx #$28
bne b7
inc by
lda by
cmp #$c8
bne b6
2018-04-01 10:32:45 +00:00
lda #DTV_HIGHCOLOR|DTV_LINEAR
sta dtv_control
jsr mode_ctrl
2018-03-27 08:01:28 +00:00
rts
row_bitmask: .byte 0, $55, $aa, $ff
}
2019-02-17 23:12:29 +00:00
// Two Plane Bitmap - generated from the two DTV linear graphics plane counters
// Two Plane Bitmap Mode (CHUNK/COLDIS/MCM = 0, ECM/BMM/HICOL/LINEAR = 1)
// Resolution: 320x200
// Linear Adressing
// GfxData/PlaneA Pixel Shifter (1), CharData/PlaneB Pixel Shifter (1):
// - Plane A = 0 Plane B = 0: 8bpp BgColor0[7:0]
// - Plane A = 0 Plane B = 1: 8bpp "0000" & ColorData[7:4]
// - Plane A = 1 Plane B = 0: 8bpp "0000" & ColorData[3:0]
// - Plane A = 1 Plane B = 1: 8bpp BgColor1[7:0]
2018-03-25 21:40:38 +00:00
mode_twoplanebitmap: {
2018-03-29 07:09:07 +00:00
.label PLANEA = $4000
.label PLANEB = $6000
.label COLORS = $8000
.label _16 = 7
.label col = 2
.label cy = 4
.label gfxa = 2
.label ay = 4
.label gfxb = 2
.label by = 4
lda #DTV_HIGHCOLOR|DTV_LINEAR
2018-03-25 21:40:38 +00:00
sta DTV_CONTROL
2019-02-17 23:12:29 +00:00
// VIC Graphics Mode
2018-03-25 21:40:38 +00:00
lda #VIC_ECM|VIC_BMM|VIC_DEN|VIC_RSEL|3
2018-03-26 19:41:09 +00:00
sta VIC_CONTROL
2018-03-25 21:40:38 +00:00
lda #VIC_CSEL
2018-03-26 19:41:09 +00:00
sta VIC_CONTROL2
2019-02-17 23:12:29 +00:00
// Linear Graphics Plane A Counter
2018-03-29 07:09:07 +00:00
lda #<PLANEA
2018-03-25 21:40:38 +00:00
sta DTV_PLANEA_START_LO
2018-03-29 07:09:07 +00:00
lda #>PLANEA
2018-03-25 21:40:38 +00:00
sta DTV_PLANEA_START_MI
lda #0
sta DTV_PLANEA_START_HI
lda #1
sta DTV_PLANEA_STEP
lda #0
sta DTV_PLANEA_MODULO_LO
sta DTV_PLANEA_MODULO_HI
2019-02-17 23:12:29 +00:00
// Linear Graphics Plane B Counter
2018-03-29 07:09:07 +00:00
lda #<PLANEB
2018-03-25 21:40:38 +00:00
sta DTV_PLANEB_START_LO
2018-03-29 07:09:07 +00:00
lda #>PLANEB
2018-03-25 21:40:38 +00:00
sta DTV_PLANEB_START_MI
lda #0
sta DTV_PLANEB_START_HI
lda #1
sta DTV_PLANEB_STEP
lda #0
sta DTV_PLANEB_MODULO_LO
sta DTV_PLANEB_MODULO_HI
2019-02-17 23:12:29 +00:00
// DTV Color Bank
2018-03-29 07:09:07 +00:00
lda #<COLORS/$400
sta DTV_COLOR_BANK_LO
2018-03-29 07:09:07 +00:00
lda #>COLORS/$400
sta DTV_COLOR_BANK_HI
ldx #0
2019-02-17 23:12:29 +00:00
// DTV Palette - Grey Tones
b1:
txa
sta DTV_PALETTE,x
inx
cpx #$10
bne b1
2019-02-17 23:12:29 +00:00
// Screen colors
lda #0
2018-03-25 21:40:38 +00:00
sta BORDERCOL
lda #$70
2018-03-25 21:40:38 +00:00
sta BGCOL1
2019-02-17 23:12:29 +00:00
// Color for bits 00
lda #$d4
2018-03-25 21:40:38 +00:00
sta BGCOL2
2018-03-29 07:09:07 +00:00
lda #<COLORS
sta col
2018-03-29 07:09:07 +00:00
lda #>COLORS
sta col+1
lda #0
sta cy
b2:
ldx #0
b3:
lda #$f
and cy
asl
asl
asl
asl
sta _16
txa
and #$f
ora _16
2018-03-25 21:40:38 +00:00
ldy #0
sta (col),y
inc col
2018-03-25 21:40:38 +00:00
bne !+
inc col+1
2018-03-25 21:40:38 +00:00
!:
inx
cpx #$28
bne b3
inc cy
lda cy
cmp #$19
bne b2
2018-03-29 07:09:07 +00:00
lda #<PLANEA
2018-03-25 21:40:38 +00:00
sta gfxa
2018-03-29 07:09:07 +00:00
lda #>PLANEA
2018-03-25 21:40:38 +00:00
sta gfxa+1
lda #0
sta ay
b4:
2018-03-25 21:40:38 +00:00
ldx #0
b5:
2018-03-25 21:40:38 +00:00
lda #4
and ay
cmp #0
beq b6
lda #$ff
ldy #0
2018-03-25 21:40:38 +00:00
sta (gfxa),y
inc gfxa
bne !+
inc gfxa+1
!:
b7:
2018-03-25 21:40:38 +00:00
inx
cpx #$28
bne b5
2018-03-25 21:40:38 +00:00
inc ay
lda ay
cmp #$c8
bne b4
2018-03-25 21:40:38 +00:00
lda #0
sta by
2018-03-29 07:09:07 +00:00
lda #<PLANEB
2018-03-25 21:40:38 +00:00
sta gfxb
2018-03-29 07:09:07 +00:00
lda #>PLANEB
2018-03-25 21:40:38 +00:00
sta gfxb+1
b8:
2018-03-25 21:40:38 +00:00
ldx #0
b9:
2018-03-25 21:40:38 +00:00
lda #$f
ldy #0
sta (gfxb),y
inc gfxb
bne !+
inc gfxb+1
!:
inx
cpx #$28
bne b9
2018-03-25 21:40:38 +00:00
inc by
lda by
cmp #$c8
bne b8
2018-04-01 10:32:45 +00:00
lda #DTV_HIGHCOLOR|DTV_LINEAR
sta dtv_control
jsr mode_ctrl
2018-03-25 21:40:38 +00:00
rts
b6:
lda #0
tay
2018-03-25 21:40:38 +00:00
sta (gfxa),y
inc gfxa
bne !+
inc gfxa+1
!:
jmp b7
2018-03-25 21:40:38 +00:00
}
2019-02-17 23:12:29 +00:00
// Sixs Fred Mode 2 - 8bpp Packed Bitmap - Generated from the two DTV linear graphics plane counters
// Two Plane MultiColor Bitmap - 8bpp Packed Bitmap (CHUNK/COLDIS/HICOL = 0, ECM/BMM/MCM/LINEAR = 1)
// Resolution: 160x200
// Linear Adressing
// PlaneA Pixel Shifter (2), PlaneB Pixel Shifter (2):
// - 8bpp color (PlaneB[1:0],ColorData[5:4],PlaneA[1:0],ColorData[1:0])
2018-03-28 14:43:47 +00:00
mode_sixsfred2: {
2018-03-29 07:09:07 +00:00
.label PLANEA = $4000
.label PLANEB = $6000
.label COLORS = $8000
2018-03-28 14:43:47 +00:00
.label _15 = 7
.label col = 2
.label cy = 4
.label gfxa = 2
.label ay = 4
.label gfxb = 2
.label by = 4
lda #DTV_LINEAR
2018-03-28 14:43:47 +00:00
sta DTV_CONTROL
2019-02-17 23:12:29 +00:00
// VIC Graphics Mode
2018-03-28 14:43:47 +00:00
lda #VIC_ECM|VIC_BMM|VIC_DEN|VIC_RSEL|3
sta VIC_CONTROL
lda #VIC_MCM|VIC_CSEL
sta VIC_CONTROL2
2019-02-17 23:12:29 +00:00
// Linear Graphics Plane A Counter
2018-03-29 07:09:07 +00:00
lda #<PLANEA
2018-03-28 14:43:47 +00:00
sta DTV_PLANEA_START_LO
2018-03-29 07:09:07 +00:00
lda #>PLANEA
2018-03-28 14:43:47 +00:00
sta DTV_PLANEA_START_MI
lda #0
sta DTV_PLANEA_START_HI
lda #1
sta DTV_PLANEA_STEP
lda #0
sta DTV_PLANEA_MODULO_LO
sta DTV_PLANEA_MODULO_HI
2019-02-17 23:12:29 +00:00
// Linear Graphics Plane B Counter
2018-03-29 07:09:07 +00:00
lda #<PLANEB
2018-03-28 14:43:47 +00:00
sta DTV_PLANEB_START_LO
2018-03-29 07:09:07 +00:00
lda #>PLANEB
2018-03-28 14:43:47 +00:00
sta DTV_PLANEB_START_MI
lda #0
sta DTV_PLANEB_START_HI
lda #1
sta DTV_PLANEB_STEP
lda #0
sta DTV_PLANEB_MODULO_LO
sta DTV_PLANEB_MODULO_HI
2019-02-17 23:12:29 +00:00
// DTV Color Bank
2018-03-29 07:09:07 +00:00
lda #<COLORS/$400
2018-03-28 14:43:47 +00:00
sta DTV_COLOR_BANK_LO
2018-03-29 07:09:07 +00:00
lda #>COLORS/$400
2018-03-28 14:43:47 +00:00
sta DTV_COLOR_BANK_HI
ldx #0
2019-02-17 23:12:29 +00:00
// DTV Palette - Grey Tones
2018-03-28 14:43:47 +00:00
b1:
txa
sta DTV_PALETTE,x
inx
cpx #$10
bne b1
2019-02-17 23:12:29 +00:00
// Screen colors
2018-03-28 14:43:47 +00:00
lda #0
sta BORDERCOL
2018-03-29 07:09:07 +00:00
lda #<COLORS
2018-03-28 14:43:47 +00:00
sta col
2018-03-29 07:09:07 +00:00
lda #>COLORS
2018-03-28 14:43:47 +00:00
sta col+1
lda #0
sta cy
b2:
ldx #0
b3:
txa
and #3
asl
asl
asl
asl
sta _15
lda #3
and cy
ora _15
ldy #0
sta (col),y
inc col
bne !+
inc col+1
!:
inx
cpx #$28
bne b3
inc cy
lda cy
cmp #$19
bne b2
2018-03-29 07:09:07 +00:00
lda #<PLANEA
2018-03-28 14:43:47 +00:00
sta gfxa
2018-03-29 07:09:07 +00:00
lda #>PLANEA
2018-03-28 14:43:47 +00:00
sta gfxa+1
lda #0
sta ay
b4:
ldx #0
b5:
lda ay
lsr
and #3
tay
lda row_bitmask,y
ldy #0
sta (gfxa),y
inc gfxa
bne !+
inc gfxa+1
!:
inx
cpx #$28
bne b5
inc ay
lda ay
cmp #$c8
bne b4
lda #0
sta by
2018-03-29 07:09:07 +00:00
lda #<PLANEB
2018-03-28 14:43:47 +00:00
sta gfxb
2018-03-29 07:09:07 +00:00
lda #>PLANEB
2018-03-28 14:43:47 +00:00
sta gfxb+1
b6:
ldx #0
b7:
lda #$1b
ldy #0
sta (gfxb),y
inc gfxb
bne !+
inc gfxb+1
!:
inx
cpx #$28
bne b7
inc by
lda by
cmp #$c8
bne b6
2018-04-01 10:32:45 +00:00
lda #DTV_LINEAR
sta dtv_control
jsr mode_ctrl
2018-03-28 14:43:47 +00:00
rts
row_bitmask: .byte 0, $55, $aa, $ff
}
2019-02-17 23:12:29 +00:00
// High Color Multicolor Character Mode (LINEAR/CHUNK/COLDIS/BMM/ECM = 0, MCM/HICOL = 1)
// Resolution: 160x200 (320x200)
// Normal VIC Adressing:
// VicGfxData[16]: ( VicBank[1:0] & CharBase[2:0] & CharData[7:0] & RowCounter[2:0] )
//GfxData Pixel Shifter (1) if ColorData[3:3] = 0:
// - 0: 8bpp BgColor0[7:0]
// - 1: 8bpp ColorData[7:4] "0" & Color[2:0]
//GfxData Pixel Shifter (2) if ColorData[3:3] = 1:
// - 00: 8bpp BgColor0[7:0]
// - 01: 8bpp BgColor1[7:0]
// - 10: 8bpp BgColor2[7:0]
// - 11: 8bpp ColorData[7:4] "0" & Color[2:0]
2018-03-29 07:09:07 +00:00
mode_hicolmcchar: {
.label SCREEN = $8000
.label CHARSET = $9000
2019-02-17 23:12:29 +00:00
// Charset ROM
2018-03-29 07:09:07 +00:00
.label COLORS = $8400
2018-03-29 06:49:51 +00:00
.label _26 = 7
.label col = 2
2018-03-29 06:49:51 +00:00
.label ch = 5
.label cy = 4
2019-02-17 23:12:29 +00:00
// DTV Graphics Bank
2018-03-29 07:09:07 +00:00
lda #($ffffffff&CHARSET)/$10000
2018-03-29 06:49:51 +00:00
sta DTV_GRAPHICS_VIC_BANK
2019-02-17 23:12:29 +00:00
// DTV Color Bank
2018-03-29 07:09:07 +00:00
lda #COLORS/$400
2018-03-29 06:49:51 +00:00
sta DTV_COLOR_BANK_LO
lda #0
sta DTV_COLOR_BANK_HI
lda #DTV_HIGHCOLOR
2018-03-29 06:49:51 +00:00
sta DTV_CONTROL
2019-02-17 23:12:29 +00:00
// VIC Graphics Bank
2018-03-29 06:49:51 +00:00
lda #3
sta CIA2_PORT_A_DDR
2019-02-17 23:12:29 +00:00
// Set VIC Bank bits to output - all others to input
2018-03-29 07:09:07 +00:00
lda #3^CHARSET/$4000
2018-03-29 06:49:51 +00:00
sta CIA2_PORT_A
2019-02-17 23:12:29 +00:00
// Set VIC Bank
// VIC Graphics Mode
2018-03-29 07:09:07 +00:00
lda #VIC_DEN|VIC_RSEL|3
2018-03-29 06:49:51 +00:00
sta VIC_CONTROL
2018-03-29 07:09:07 +00:00
lda #VIC_CSEL|VIC_MCM
2018-03-29 06:49:51 +00:00
sta VIC_CONTROL2
2019-02-17 23:12:29 +00:00
// VIC Memory Pointers
2018-03-29 07:09:07 +00:00
lda #(SCREEN&$3fff)/$40|(CHARSET&$3fff)/$400
2018-03-29 06:49:51 +00:00
sta VIC_MEMORY
ldx #0
2019-02-17 23:12:29 +00:00
// DTV Palette - Grey Tones
2018-03-29 06:49:51 +00:00
b1:
txa
sta DTV_PALETTE,x
inx
cpx #$10
bne b1
2019-02-17 23:12:29 +00:00
// Screen colors
2018-03-29 06:49:51 +00:00
lda #0
sta BORDERCOL
lda #$50
sta BGCOL1
lda #$54
sta BGCOL2
lda #$58
sta BGCOL3
2018-03-29 07:09:07 +00:00
lda #<SCREEN
2018-03-29 06:49:51 +00:00
sta ch
2018-03-29 07:09:07 +00:00
lda #>SCREEN
2018-03-29 06:49:51 +00:00
sta ch+1
2018-03-29 07:09:07 +00:00
lda #<COLORS
2018-03-29 06:49:51 +00:00
sta col
2018-03-29 07:09:07 +00:00
lda #>COLORS
2018-03-29 06:49:51 +00:00
sta col+1
lda #0
sta cy
b2:
ldx #0
b3:
lda #$f
and cy
asl
asl
asl
asl
sta _26
txa
and #$f
ora _26
ldy #0
sta (col),y
inc col
bne !+
inc col+1
!:
2018-03-29 07:09:07 +00:00
ldy #0
sta (ch),y
inc ch
bne !+
inc ch+1
!:
inx
cpx #$28
bne b3
inc cy
lda cy
cmp #$19
bne b2
2018-04-01 10:32:45 +00:00
lda #DTV_HIGHCOLOR
sta dtv_control
jsr mode_ctrl
2018-03-29 07:09:07 +00:00
rts
}
2019-02-17 23:12:29 +00:00
// High Color Extended Background Color Character Mode (LINEAR/CHUNK/COLDIS/MCM/BMM = 0, ECM/HICOL = 1)
// Resolution: 320x200
// Normal VIC Adressing:
// VicGfxData[16]: ( VicBank[1:0] & CharBase[2:0] & "00" & CharData[5:0] & RowCounter[2:0] )
// GfxData Pixel Shifter (1)
// - 0: 8bpp Background Color
// - CharData[7:6] 00: 8bpp BgColor0[7:0]
// - CharData[7:6] 01: 8bpp BgColor1[7:0]
// - CharData[7:6] 10: 8bpp BgColor2[7:0]
// - CharData[7:6] 11: 8bpp BgColor3[7:0]
// - 1: 8bpp ColorData[7:0]
2018-03-29 07:09:07 +00:00
mode_hicolecmchar: {
.label SCREEN = $8000
.label CHARSET = $9000
2019-02-17 23:12:29 +00:00
// Charset ROM
2018-03-29 07:09:07 +00:00
.label COLORS = $8400
.label _26 = 7
.label col = 2
2018-03-29 07:09:07 +00:00
.label ch = 5
.label cy = 4
2019-02-17 23:12:29 +00:00
// DTV Graphics Bank
2018-03-29 07:09:07 +00:00
lda #($ffffffff&CHARSET)/$10000
sta DTV_GRAPHICS_VIC_BANK
2019-02-17 23:12:29 +00:00
// DTV Color Bank
2018-03-29 07:09:07 +00:00
lda #COLORS/$400
sta DTV_COLOR_BANK_LO
lda #0
sta DTV_COLOR_BANK_HI
lda #DTV_HIGHCOLOR
2018-03-29 07:09:07 +00:00
sta DTV_CONTROL
2019-02-17 23:12:29 +00:00
// VIC Graphics Bank
2018-03-29 07:09:07 +00:00
lda #3
sta CIA2_PORT_A_DDR
2019-02-17 23:12:29 +00:00
// Set VIC Bank bits to output - all others to input
2018-03-29 07:09:07 +00:00
lda #3^CHARSET/$4000
sta CIA2_PORT_A
2019-02-17 23:12:29 +00:00
// Set VIC Bank
// VIC Graphics Mode
2018-03-29 07:09:07 +00:00
lda #VIC_DEN|VIC_RSEL|VIC_ECM|3
sta VIC_CONTROL
lda #VIC_CSEL
sta VIC_CONTROL2
2019-02-17 23:12:29 +00:00
// VIC Memory Pointers
2018-03-29 07:09:07 +00:00
lda #(SCREEN&$3fff)/$40|(CHARSET&$3fff)/$400
sta VIC_MEMORY
ldx #0
2019-02-17 23:12:29 +00:00
// DTV Palette - Grey Tones
2018-03-29 07:09:07 +00:00
b1:
txa
sta DTV_PALETTE,x
inx
cpx #$10
bne b1
2019-02-17 23:12:29 +00:00
// Screen colors
2018-03-29 07:09:07 +00:00
lda #0
sta BORDERCOL
lda #$50
sta BGCOL1
lda #$54
sta BGCOL2
lda #$58
sta BGCOL3
lda #$5c
sta BGCOL4
lda #<SCREEN
sta ch
lda #>SCREEN
sta ch+1
lda #<COLORS
sta col
lda #>COLORS
sta col+1
lda #0
sta cy
b2:
ldx #0
b3:
2018-03-29 06:49:51 +00:00
lda #$f
and cy
asl
asl
asl
asl
2018-03-29 07:09:07 +00:00
sta _26
2018-03-29 06:49:51 +00:00
txa
and #$f
2018-03-29 07:09:07 +00:00
ora _26
ldy #0
sta (col),y
inc col
bne !+
inc col+1
!:
2018-03-29 06:49:51 +00:00
ldy #0
sta (ch),y
inc ch
bne !+
inc ch+1
!:
inx
cpx #$28
bne b3
inc cy
lda cy
cmp #$19
bne b2
2018-04-01 10:32:45 +00:00
lda #DTV_HIGHCOLOR
sta dtv_control
jsr mode_ctrl
2018-03-29 06:49:51 +00:00
rts
}
2019-02-17 23:12:29 +00:00
// High Color Standard Character Mode (LINEAR/CHUNK/COLDIS/ECM/MCM/BMM = 0, HICOL = 1)
// Resolution: 320x200
// Normal VIC Adressing:
// VicGfxData[16]: ( VicBank[1:0] & CharBase[2:0] & CharData[7:0] & RowCounter[2:0] )
// Pixel Shifter (1)
// - 0: 8bpp BgColor0[7:0]
// - 1: 8bpp ColorData[7:0]
mode_hicolstdchar: {
2018-03-29 07:09:07 +00:00
.label SCREEN = $8000
.label CHARSET = $9000
2019-02-17 23:12:29 +00:00
// Charset ROM
2018-03-29 07:09:07 +00:00
.label COLORS = $8400
.label _25 = 7
.label col = 2
.label ch = 5
.label cy = 4
2019-02-17 23:12:29 +00:00
// DTV Graphics Bank
2018-03-29 07:09:07 +00:00
lda #($ffffffff&CHARSET)/$10000
sta DTV_GRAPHICS_VIC_BANK
2019-02-17 23:12:29 +00:00
// DTV Color Bank
2018-03-29 07:09:07 +00:00
lda #COLORS/$400
sta DTV_COLOR_BANK_LO
lda #0
sta DTV_COLOR_BANK_HI
lda #DTV_HIGHCOLOR
sta DTV_CONTROL
2019-02-17 23:12:29 +00:00
// VIC Graphics Bank
lda #3
sta CIA2_PORT_A_DDR
2019-02-17 23:12:29 +00:00
// Set VIC Bank bits to output - all others to input
2018-03-29 07:09:07 +00:00
lda #3^CHARSET/$4000
sta CIA2_PORT_A
2019-02-17 23:12:29 +00:00
// Set VIC Bank
// VIC Graphics Mode
lda #VIC_DEN|VIC_RSEL|3
sta VIC_CONTROL
lda #VIC_CSEL
sta VIC_CONTROL2
2019-02-17 23:12:29 +00:00
// VIC Memory Pointers
2018-03-29 07:09:07 +00:00
lda #(SCREEN&$3fff)/$40|(CHARSET&$3fff)/$400
sta VIC_MEMORY
ldx #0
2019-02-17 23:12:29 +00:00
// DTV Palette - Grey Tones
b1:
txa
sta DTV_PALETTE,x
inx
cpx #$10
bne b1
2019-02-17 23:12:29 +00:00
// Screen colors
lda #0
sta BGCOL
sta BORDERCOL
2018-03-29 07:09:07 +00:00
lda #<SCREEN
sta ch
2018-03-29 07:09:07 +00:00
lda #>SCREEN
sta ch+1
2018-03-29 07:09:07 +00:00
lda #<COLORS
sta col
2018-03-29 07:09:07 +00:00
lda #>COLORS
sta col+1
lda #0
sta cy
b2:
ldx #0
b3:
lda #$f
and cy
asl
asl
asl
asl
sta _25
txa
and #$f
ora _25
ldy #0
sta (col),y
inc col
bne !+
inc col+1
!:
ldy #0
sta (ch),y
inc ch
bne !+
inc ch+1
!:
inx
cpx #$28
bne b3
inc cy
lda cy
cmp #$19
bne b2
2018-04-01 10:32:45 +00:00
lda #DTV_HIGHCOLOR
sta dtv_control
jsr mode_ctrl
rts
}
2019-02-17 23:12:29 +00:00
// Standard Bitmap Mode (LINEAR/HICOL/CHUNK/COLDIS/MCM/ECM = 0, BMM = 1)
// Resolution: 320x200
// Normal VIC Adressing:
// VicGfxData[16]: ( VicBank[1:0] & CharBase[2:2] & Matrix[9:0] & RowCounter[2:0] )
// Pixel Shifter (1)
// - 0: 4bpp CharData[3:0]
// - 1: 4bpp CharData[7:4]
mode_stdbitmap: {
.label SCREEN = $4000
.label BITMAP = $6000
.const lines_cnt = 9
.label col2 = 7
.label ch = 2
.label cy = 4
.label l = 4
2019-02-17 23:12:29 +00:00
// DTV Graphics Bank
lda #($ffffffff&BITMAP)/$10000
sta DTV_GRAPHICS_VIC_BANK
lda #0
sta DTV_CONTROL
2019-02-17 23:12:29 +00:00
// VIC Graphics Bank
lda #3
sta CIA2_PORT_A_DDR
2019-02-17 23:12:29 +00:00
// Set VIC Bank bits to output - all others to input
lda #3^BITMAP/$4000
sta CIA2_PORT_A
2019-02-17 23:12:29 +00:00
// Set VIC Bank
// VIC Graphics Mode
lda #VIC_BMM|VIC_DEN|VIC_RSEL|3
sta VIC_CONTROL
lda #VIC_CSEL
sta VIC_CONTROL2
2019-02-17 23:12:29 +00:00
// VIC Memory Pointers
lda #(SCREEN&$3fff)/$40|(BITMAP&$3fff)/$400
sta VIC_MEMORY
ldx #0
2019-02-17 23:12:29 +00:00
// DTV Palette - default
b1:
lda DTV_PALETTE_DEFAULT,x
sta DTV_PALETTE,x
inx
cpx #$10
bne b1
2019-02-17 23:12:29 +00:00
// Screen colors
lda #BLACK
sta BGCOL
sta BORDERCOL
lda #<SCREEN
sta ch
lda #>SCREEN
sta ch+1
lda #0
sta cy
b2:
ldx #0
b3:
txa
clc
adc cy
and #$f
tay
tya
eor #$ff
clc
adc #$f+1
sta col2
tya
asl
asl
asl
asl
ora col2
ldy #0
sta (ch),y
inc ch
bne !+
inc ch+1
!:
inx
cpx #$28
bne b3
inc cy
lda cy
cmp #$19
bne b2
jsr bitmap_init
jsr bitmap_clear
lda #0
sta l
b4:
ldy l
lda lines_x,y
sta bitmap_line.x0
lda lines_x+1,y
sta bitmap_line.x1
lda lines_y,y
sta bitmap_line.y0
ldx l
ldy lines_y+1,x
jsr bitmap_line
inc l
lda l
cmp #lines_cnt
bcc b4
2018-04-01 10:32:45 +00:00
lda #0
sta dtv_control
jsr mode_ctrl
rts
lines_x: .byte 0, $ff, $ff, 0, 0, $80, $ff, $80, 0, $80
lines_y: .byte 0, 0, $c7, $c7, 0, 0, $64, $c7, $64, 0
}
2019-02-17 23:12:29 +00:00
// Draw a line on the bitmap
bitmap_line: {
.label xd = 8
.label yd = 7
.label x0 = 9
.label x1 = $c
.label y0 = $b
lda x0
cmp x1
bcc b1
sec
sbc x1
sta xd
tya
cmp y0
beq !+
bcs b2
!:
tya
eor #$ff
sec
adc y0
sta yd
cmp xd
bcc b3
sty bitmap_line_ydxi.y
ldx x1
jsr bitmap_line_ydxi
breturn:
rts
b3:
lda x1
sta bitmap_line_xdyi.x
sty bitmap_line_xdyi.y
jsr bitmap_line_xdyi
jmp breturn
b2:
tya
sec
sbc y0
sta yd
cmp xd
bcc b6
lda y0
sta bitmap_line_ydxd.y
ldx x0
sty bitmap_line_ydxd.y1
jsr bitmap_line_ydxd
jmp breturn
b6:
lda x1
sta bitmap_line_xdyd.x
sty bitmap_line_xdyd.y
lda x0
sta bitmap_line_xdyd.x1
jsr bitmap_line_xdyd
jmp breturn
b1:
lda x1
sec
sbc x0
sta xd
tya
cmp y0
beq !+
bcs b9
!:
tya
eor #$ff
sec
adc y0
sta yd
cmp xd
bcc b10
sty bitmap_line_ydxd.y
ldx x1
jsr bitmap_line_ydxd
jmp breturn
b10:
lda x0
sta bitmap_line_xdyd.x
jsr bitmap_line_xdyd
jmp breturn
b9:
tya
sec
sbc y0
sta yd
cmp xd
bcc b13
lda y0
sta bitmap_line_ydxi.y
ldx x0
sty bitmap_line_ydxi.y1
jsr bitmap_line_ydxi
jmp breturn
b13:
lda x0
sta bitmap_line_xdyi.x
lda x1
sta bitmap_line_xdyi.x1
jsr bitmap_line_xdyi
jmp breturn
}
bitmap_line_xdyi: {
.label x = $a
.label y = $b
.label x1 = 9
.label xd = 8
.label yd = 7
.label e = $c
lda yd
lsr
sta e
b1:
ldx x
ldy y
jsr bitmap_plot
inc x
lda e
clc
adc yd
sta e
lda xd
cmp e
bcs b2
inc y
lda e
sec
sbc xd
sta e
b2:
ldx x1
inx
cpx x
bne b1
rts
}
bitmap_plot: {
.label _0 = 2
.label plotter_x = 2
.label plotter_y = 5
lda bitmap_plot_xhi,x
sta plotter_x+1
lda bitmap_plot_xlo,x
sta plotter_x
lda bitmap_plot_yhi,y
sta plotter_y+1
lda bitmap_plot_ylo,y
sta plotter_y
lda _0
clc
adc plotter_y
sta _0
lda _0+1
adc plotter_y+1
sta _0+1
lda bitmap_plot_bit,x
ldy #0
ora (_0),y
sta (_0),y
rts
}
bitmap_line_ydxi: {
.label y = $a
.label y1 = $b
.label yd = 7
.label xd = 8
.label e = 9
lda xd
lsr
sta e
b1:
ldy y
jsr bitmap_plot
inc y
lda e
clc
adc xd
sta e
lda yd
cmp e
bcs b2
inx
lda e
sec
sbc yd
sta e
b2:
lda y1
clc
adc #1
cmp y
bne b1
rts
}
bitmap_line_xdyd: {
.label x = $a
.label y = $b
.label x1 = $c
.label xd = 8
.label yd = 7
.label e = 9
lda yd
lsr
sta e
b1:
ldx x
ldy y
jsr bitmap_plot
inc x
lda e
clc
adc yd
sta e
lda xd
cmp e
bcs b2
dec y
lda e
sec
sbc xd
sta e
b2:
ldx x1
inx
cpx x
bne b1
rts
}
bitmap_line_ydxd: {
.label y = $a
.label y1 = $b
.label yd = 7
.label xd = 8
.label e = 9
lda xd
lsr
sta e
b1:
ldy y
jsr bitmap_plot
inc y
lda e
clc
adc xd
sta e
lda yd
cmp e
bcs b2
dex
lda e
sec
sbc yd
sta e
b2:
lda y1
clc
adc #1
cmp y
bne b1
rts
}
2019-02-17 23:12:29 +00:00
// Clear all graphics on the bitmap
bitmap_clear: {
.label bitmap = 2
.label y = 4
.label _3 = 2
lda bitmap_plot_xlo
sta _3
lda bitmap_plot_xhi
sta _3+1
lda #0
sta y
b1:
ldx #0
b2:
lda #0
tay
sta (bitmap),y
inc bitmap
bne !+
inc bitmap+1
!:
inx
cpx #$c8
bne b2
inc y
lda y
cmp #$28
bne b1
rts
}
2019-02-17 23:12:29 +00:00
// Initialize the bitmap plotter tables for a specific bitmap
bitmap_init: {
.label _6 = 4
.label yoffs = 2
ldy #$80
ldx #0
b1:
txa
and #$f8
sta bitmap_plot_xlo,x
lda #>mode_stdbitmap.BITMAP
sta bitmap_plot_xhi,x
tya
sta bitmap_plot_bit,x
tya
lsr
tay
cpy #0
bne b2
ldy #$80
b2:
inx
cpx #0
bne b1
lda #<0
sta yoffs
sta yoffs+1
tax
b3:
txa
and #7
sta _6
lda yoffs
ora _6
sta bitmap_plot_ylo,x
lda yoffs+1
sta bitmap_plot_yhi,x
txa
and #7
cmp #7
bne b4
clc
lda yoffs
adc #<$28*8
sta yoffs
lda yoffs+1
adc #>$28*8
sta yoffs+1
b4:
inx
cpx #0
bne b3
rts
}
2019-02-17 23:12:29 +00:00
// Multicolor Character Mode (LINEAR/HICOL/CHUNK/COLDIS/BMM/ECM = 0, MCM = 1)
// Resolution: 160x200 (320x200)
// Normal VIC Adressing:
// VicGfxData[16]: ( VicBank[1:0] & CharBase[2:0] & CharData[7:0] & RowCounter[2:0] )
// GfxData Pixel Shifter (1) if ColorData[3:3] = 0:
// - 0: 4bpp BgColor0[3:0]
// - 1: 4bpp ColorData[2:0]
// GfxData Pixel Shifter (2) if ColorData[3:3] = 1:
// - 00: 4bpp BgColor0[3:0]
// - 01: 4bpp BgColor1[3:0]
// - 10: 4bpp BgColor2[3:0]
// - 11: 4bpp ColorData[2:0]// Standard Character Mode (LINEAR/HICOL/CHUNK/COLDIS/ECM/MCM/BMM = 0)
2018-03-29 07:09:07 +00:00
mode_mcchar: {
2018-03-29 06:49:51 +00:00
.label SCREEN = $8000
.label CHARSET = $9000
2019-02-17 23:12:29 +00:00
// Charset ROM
.label COLORS = $d800
2018-03-29 06:49:51 +00:00
.label _28 = 7
.label col = 2
2018-03-29 06:49:51 +00:00
.label ch = 5
.label cy = 4
2019-02-17 23:12:29 +00:00
// DTV Graphics Bank
2018-03-29 06:49:51 +00:00
lda #($ffffffff&CHARSET)/$10000
sta DTV_GRAPHICS_VIC_BANK
2019-02-17 23:12:29 +00:00
// DTV Color Bank
lda #DTV_COLOR_BANK_DEFAULT/$400
2018-03-29 06:49:51 +00:00
sta DTV_COLOR_BANK_LO
lda #0
sta DTV_COLOR_BANK_HI
sta DTV_CONTROL
2019-02-17 23:12:29 +00:00
// VIC Graphics Bank
2018-03-29 06:49:51 +00:00
lda #3
sta CIA2_PORT_A_DDR
2019-02-17 23:12:29 +00:00
// Set VIC Bank bits to output - all others to input
2018-03-29 06:49:51 +00:00
lda #3^CHARSET/$4000
sta CIA2_PORT_A
2019-02-17 23:12:29 +00:00
// Set VIC Bank
// VIC Graphics Mode
2018-03-29 06:49:51 +00:00
lda #VIC_DEN|VIC_RSEL|3
sta VIC_CONTROL
lda #VIC_CSEL|VIC_MCM
sta VIC_CONTROL2
2019-02-17 23:12:29 +00:00
// VIC Memory Pointers
2018-03-29 06:49:51 +00:00
lda #(SCREEN&$3fff)/$40|(CHARSET&$3fff)/$400
sta VIC_MEMORY
ldx #0
2019-02-17 23:12:29 +00:00
// DTV Palette - default
2018-03-29 06:49:51 +00:00
b1:
lda DTV_PALETTE_DEFAULT,x
sta DTV_PALETTE,x
inx
cpx #$10
bne b1
2019-02-17 23:12:29 +00:00
// Screen colors
2018-03-29 06:49:51 +00:00
lda #0
sta BORDERCOL
lda #BLACK
sta BGCOL1
lda #GREEN
sta BGCOL2
lda #BLUE
sta BGCOL3
lda #<SCREEN
sta ch
lda #>SCREEN
sta ch+1
lda #<COLORS
sta col
lda #>COLORS
sta col+1
lda #0
sta cy
b2:
ldx #0
b3:
txa
clc
adc cy
and #$f
ldy #0
sta (col),y
inc col
bne !+
inc col+1
!:
lda #$f
and cy
asl
asl
asl
asl
sta _28
txa
and #$f
ora _28
ldy #0
sta (ch),y
inc ch
bne !+
inc ch+1
!:
inx
cpx #$28
bne b3
inc cy
lda cy
cmp #$19
bne b2
2018-04-01 10:32:45 +00:00
lda #0
sta dtv_control
jsr mode_ctrl
2018-03-29 06:49:51 +00:00
rts
}
2019-02-17 23:12:29 +00:00
// Extended Background Color Character Mode (LINEAR/HICOL/CHUNK/COLDIS/MCM/BMM = 0, ECM = 1)
// Resolution: 320x200
// Normal VIC Adressing:
// VicGfxData[16]: ( VicBank[1:0] & CharBase[2:0] & "00" & CharData[5:0] & RowCounter[2:0] )
// GfxData Pixel Shifter (1)
// - 0: 4bpp Background Color
// - CharData[7:6] 00: 4bpp BgColor0[3:0]
// - CharData[7:6] 01: 4bpp BgColor1[3:0]
// - CharData[7:6] 10: 4bpp BgColor2[3:0]
// - CharData[7:6] 11: 4bpp BgColor3[3:0]
// - 1: 4bpp ColorData[3:0]
mode_ecmchar: {
.label SCREEN = $8000
.label CHARSET = $9000
2019-02-17 23:12:29 +00:00
// Charset ROM
.label COLORS = $d800
.label _28 = 7
.label col = 2
.label ch = 5
.label cy = 4
2019-02-17 23:12:29 +00:00
// DTV Graphics Bank
lda #($ffffffff&CHARSET)/$10000
sta DTV_GRAPHICS_VIC_BANK
2019-02-17 23:12:29 +00:00
// DTV Color Bank
lda #DTV_COLOR_BANK_DEFAULT/$400
sta DTV_COLOR_BANK_LO
lda #0
sta DTV_COLOR_BANK_HI
sta DTV_CONTROL
2019-02-17 23:12:29 +00:00
// VIC Graphics Bank
lda #3
sta CIA2_PORT_A_DDR
2019-02-17 23:12:29 +00:00
// Set VIC Bank bits to output - all others to input
lda #3^CHARSET/$4000
sta CIA2_PORT_A
2019-02-17 23:12:29 +00:00
// Set VIC Bank
// VIC Graphics Mode
lda #VIC_DEN|VIC_RSEL|VIC_ECM|3
sta VIC_CONTROL
lda #VIC_CSEL
sta VIC_CONTROL2
2019-02-17 23:12:29 +00:00
// VIC Memory Pointers
lda #(SCREEN&$3fff)/$40|(CHARSET&$3fff)/$400
sta VIC_MEMORY
ldx #0
2019-02-17 23:12:29 +00:00
// DTV Palette - default
b1:
lda DTV_PALETTE_DEFAULT,x
sta DTV_PALETTE,x
inx
cpx #$10
bne b1
2019-02-17 23:12:29 +00:00
// Screen colors
lda #0
sta BORDERCOL
sta BGCOL1
lda #2
sta BGCOL2
lda #5
sta BGCOL3
lda #6
sta BGCOL4
lda #<SCREEN
sta ch
lda #>SCREEN
sta ch+1
lda #<COLORS
sta col
lda #>COLORS
sta col+1
lda #0
sta cy
b2:
ldx #0
b3:
txa
clc
adc cy
and #$f
ldy #0
sta (col),y
inc col
bne !+
inc col+1
!:
lda #$f
and cy
asl
asl
asl
asl
sta _28
txa
and #$f
ora _28
ldy #0
sta (ch),y
inc ch
bne !+
inc ch+1
!:
inx
cpx #$28
bne b3
inc cy
lda cy
cmp #$19
bne b2
2018-04-01 10:32:45 +00:00
lda #0
sta dtv_control
jsr mode_ctrl
rts
}
2019-02-17 23:12:29 +00:00
// Standard Character Mode (LINEAR/HICOL/CHUNK/COLDIS/ECM/MCM/BMM = 0)
// Resolution: 320x200
// Normal VIC Adressing:
// VicGfxData[16]: ( VicBank[1:0] & CharBase[2:0] & CharData[7:0] & RowCounter[2:0] )
// Pixel Shifter (1)
// - 0: 4bpp BgColor0[3:0]
// - 1: 4bpp ColorData[3:0]
mode_stdchar: {
2018-03-29 07:09:07 +00:00
.label SCREEN = $8000
.label CHARSET = $9000
2019-02-17 23:12:29 +00:00
// Charset ROM
.label COLORS = $d800
.label _27 = 7
.label col = 2
.label ch = 5
.label cy = 4
2019-02-17 23:12:29 +00:00
// DTV Graphics Bank
2018-03-29 07:09:07 +00:00
lda #($ffffffff&CHARSET)/$10000
sta DTV_GRAPHICS_VIC_BANK
2019-02-17 23:12:29 +00:00
// DTV Color Bank
lda #DTV_COLOR_BANK_DEFAULT/$400
sta DTV_COLOR_BANK_LO
lda #0
sta DTV_COLOR_BANK_HI
sta DTV_CONTROL
2019-02-17 23:12:29 +00:00
// VIC Graphics Bank
lda #3
sta CIA2_PORT_A_DDR
2019-02-17 23:12:29 +00:00
// Set VIC Bank bits to output - all others to input
2018-03-29 07:09:07 +00:00
lda #3^CHARSET/$4000
sta CIA2_PORT_A
2019-02-17 23:12:29 +00:00
// Set VIC Bank
// VIC Graphics Mode
lda #VIC_DEN|VIC_RSEL|3
sta VIC_CONTROL
lda #VIC_CSEL
sta VIC_CONTROL2
2019-02-17 23:12:29 +00:00
// VIC Memory Pointers
2018-03-29 07:09:07 +00:00
lda #(SCREEN&$3fff)/$40|(CHARSET&$3fff)/$400
sta VIC_MEMORY
ldx #0
2019-02-17 23:12:29 +00:00
// DTV Palette - default
b1:
lda DTV_PALETTE_DEFAULT,x
sta DTV_PALETTE,x
inx
cpx #$10
bne b1
2019-02-17 23:12:29 +00:00
// Screen colors
lda #0
sta BGCOL
sta BORDERCOL
2018-03-29 07:09:07 +00:00
lda #<SCREEN
sta ch
2018-03-29 07:09:07 +00:00
lda #>SCREEN
sta ch+1
2018-03-29 07:09:07 +00:00
lda #<COLORS
sta col
2018-03-29 07:09:07 +00:00
lda #>COLORS
sta col+1
lda #0
sta cy
b2:
ldx #0
b3:
txa
clc
adc cy
and #$f
ldy #0
sta (col),y
inc col
bne !+
inc col+1
!:
lda #$f
and cy
asl
asl
asl
asl
sta _27
txa
and #$f
ora _27
ldy #0
sta (ch),y
inc ch
bne !+
inc ch+1
!:
inx
cpx #$28
bne b3
inc cy
lda cy
cmp #$19
bne b2
2018-04-01 10:32:45 +00:00
lda #0
sta dtv_control
jsr mode_ctrl
rts
}
2019-02-17 23:12:29 +00:00
// Print a number of zero-terminated strings, each followed by a newline.
// The sequence of lines is terminated by another zero.
2018-03-26 19:41:09 +00:00
print_str_lines: {
.label str = 2
2018-03-29 07:09:07 +00:00
lda #<menu.SCREEN
2018-03-26 19:41:09 +00:00
sta print_line_cursor
2018-03-29 07:09:07 +00:00
lda #>menu.SCREEN
2018-03-26 19:41:09 +00:00
sta print_line_cursor+1
2018-03-29 07:09:07 +00:00
lda #<menu.SCREEN
2018-03-26 19:41:09 +00:00
sta print_char_cursor
2018-03-29 07:09:07 +00:00
lda #>menu.SCREEN
2018-03-26 19:41:09 +00:00
sta print_char_cursor+1
lda #<MENU_TEXT
sta str
lda #>MENU_TEXT
sta str+1
b1:
ldy #0
lda (str),y
cmp #'@'
bne b4
2018-03-25 21:40:38 +00:00
rts
2018-03-26 19:41:09 +00:00
b4:
ldy #0
lda (str),y
inc str
bne !+
inc str+1
!:
cmp #'@'
beq b5
ldy #0
sta (print_char_cursor),y
inc print_char_cursor
bne !+
inc print_char_cursor+1
!:
b5:
cmp #'@'
bne b4
jsr print_ln
lda print_line_cursor
sta print_char_cursor
lda print_line_cursor+1
sta print_char_cursor+1
jmp b1
2018-03-25 21:40:38 +00:00
}
2019-02-17 23:12:29 +00:00
// Print a newline
2018-03-25 21:40:38 +00:00
print_ln: {
b1:
lda print_line_cursor
clc
adc #$28
sta print_line_cursor
bcc !+
inc print_line_cursor+1
!:
lda print_line_cursor+1
cmp print_char_cursor+1
bcc b1
bne !+
lda print_line_cursor
cmp print_char_cursor
bcc b1
!:
rts
}
2019-02-17 23:12:29 +00:00
// Clear the screen. Also resets current line/char cursor.
2018-03-25 21:40:38 +00:00
print_cls: {
.label sc = 2
2018-03-29 07:09:07 +00:00
lda #<menu.SCREEN
2018-03-25 21:40:38 +00:00
sta sc
2018-03-29 07:09:07 +00:00
lda #>menu.SCREEN
2018-03-25 21:40:38 +00:00
sta sc+1
b1:
lda #' '
ldy #0
sta (sc),y
inc sc
bne !+
inc sc+1
!:
lda sc+1
2018-03-29 07:09:07 +00:00
cmp #>menu.SCREEN+$3e8
2018-03-25 21:40:38 +00:00
bne b1
lda sc
2018-03-29 07:09:07 +00:00
cmp #<menu.SCREEN+$3e8
2018-03-25 21:40:38 +00:00
bne b1
rts
}
2019-02-17 23:12:29 +00:00
// Set the screen to print on. Also resets current line/char cursor.
2018-03-25 21:40:38 +00:00
print_set_screen: {
rts
}
2019-02-17 23:12:29 +00:00
// Default vallues for the palette
DTV_PALETTE_DEFAULT: .byte 0, $f, $36, $be, $58, $db, $86, $ff, $29, $26, $3b, 5, 7, $df, $9a, $a
2019-02-17 23:12:29 +00:00
// Keyboard row bitmask as expected by CIA#1 Port A when reading a specific keyboard matrix row (rows are numbered 0-7)
2018-03-25 21:40:38 +00:00
keyboard_matrix_row_bitmask: .byte $fe, $fd, $fb, $f7, $ef, $df, $bf, $7f
2019-02-17 23:12:29 +00:00
// Keyboard matrix column bitmasks for a specific keybooard matrix column when reading the keyboard. (columns are numbered 0-7)
2018-03-25 21:40:38 +00:00
keyboard_matrix_col_bitmask: .byte 1, 2, 4, 8, $10, $20, $40, $80
2019-02-17 23:12:29 +00:00
// Tables for the plotter - initialized by calling bitmap_draw_init();
bitmap_plot_xlo: .fill $100, 0
bitmap_plot_xhi: .fill $100, 0
bitmap_plot_ylo: .fill $100, 0
bitmap_plot_yhi: .fill $100, 0
bitmap_plot_bit: .fill $100, 0
2018-03-27 08:01:28 +00:00
MENU_TEXT: .text "C64DTV Graphics Modes CCLHBME@"+" OHIIMCC@"+" LUNCMMM@"+"----------------------------------------@"+"1. Standard Char (V) 0000000@"+"2. Extended Color Char (V) 0000001@"+"3. Multicolor Char (V) 0000010@"+"4. Standard Bitmap (V) 0000100@"+"5. Multicolor Bitmap (V) 0000110@"+"6. High Color Standard Char (H) 0001000@"+"7. High Extended Color Char (H) 0001001@"+"8. High Multicolor Char (H) 0001010@"+"9. High Multicolor Bitmap (H) 0001110@"+"a. Sixs Fred 2 (D) 0010111@"+"b. Two Plane Bitmap (D) 0011101@"+"c. Sixs Fred (2 Plane MC BM) (D) 0011111@"+"d. 8bpp Pixel Cell (D) 0111011@"+"e. Chunky 8bpp Bitmap (D) 1111011@"+"----------------------------------------@"+" (V) vicII (H) vicII+hicol (D) c64dtv@"+"@"