2019-09-27 07:38:51 +00:00
|
|
|
;
|
2019-12-25 15:56:32 +00:00
|
|
|
; CX16 r35 definitions
|
2019-09-27 07:38:51 +00:00
|
|
|
;
|
|
|
|
|
|
|
|
; ---------------------------------------------------------------------------
|
|
|
|
; Constants
|
|
|
|
|
|
|
|
.enum COLOR
|
|
|
|
BLACK = $00
|
|
|
|
WHITE
|
|
|
|
RED
|
|
|
|
CYAN
|
|
|
|
VIOLET
|
|
|
|
PURPLE = VIOLET
|
|
|
|
GREEN
|
|
|
|
BLUE
|
|
|
|
YELLOW
|
|
|
|
ORANGE
|
|
|
|
BROWN
|
|
|
|
LIGHTRED
|
|
|
|
GRAY1
|
|
|
|
GRAY2
|
|
|
|
LIGHTGREEN
|
|
|
|
LIGHTBLUE
|
|
|
|
GRAY3
|
|
|
|
.endenum
|
|
|
|
|
|
|
|
; Special keys
|
|
|
|
.enum KEY
|
|
|
|
F1 = $85
|
|
|
|
F3
|
|
|
|
F5
|
|
|
|
F7
|
|
|
|
F2
|
|
|
|
F4
|
|
|
|
F6
|
|
|
|
F8
|
|
|
|
F9 = $10
|
|
|
|
F10 = $15
|
|
|
|
F11
|
|
|
|
F12
|
|
|
|
.endenum
|
|
|
|
|
|
|
|
; ---------------------------------------------------------------------------
|
|
|
|
; Zero page
|
|
|
|
|
2019-12-25 15:56:32 +00:00
|
|
|
; GEOS and graphics pseudo-registers
|
|
|
|
.struct gREG
|
|
|
|
.org $02
|
|
|
|
.union
|
|
|
|
r0 .word
|
|
|
|
.struct
|
|
|
|
r0L .byte
|
|
|
|
r0H .byte
|
|
|
|
.endstruct
|
|
|
|
.endunion
|
|
|
|
.union
|
|
|
|
r1 .word
|
|
|
|
.struct
|
|
|
|
r1L .byte
|
|
|
|
r1H .byte
|
|
|
|
.endstruct
|
|
|
|
.endunion
|
|
|
|
.union
|
|
|
|
r2 .word
|
|
|
|
.struct
|
|
|
|
r2L .byte
|
|
|
|
r2H .byte
|
|
|
|
.endstruct
|
|
|
|
.endunion
|
|
|
|
.union
|
|
|
|
r3 .word
|
|
|
|
.struct
|
|
|
|
r3L .byte
|
|
|
|
r3H .byte
|
|
|
|
.endstruct
|
|
|
|
.endunion
|
|
|
|
.union
|
|
|
|
r4 .word
|
|
|
|
.struct
|
|
|
|
r4L .byte
|
|
|
|
r4H .byte
|
|
|
|
.endstruct
|
|
|
|
.endunion
|
|
|
|
.union
|
|
|
|
r5 .word
|
|
|
|
.struct
|
|
|
|
r5L .byte
|
|
|
|
r5H .byte
|
|
|
|
.endstruct
|
|
|
|
.endunion
|
|
|
|
.union
|
|
|
|
r6 .word
|
|
|
|
.struct
|
|
|
|
r6L .byte
|
|
|
|
r6H .byte
|
|
|
|
.endstruct
|
|
|
|
.endunion
|
|
|
|
.union
|
|
|
|
r7 .word
|
|
|
|
.struct
|
|
|
|
r7L .byte
|
|
|
|
r7H .byte
|
|
|
|
.endstruct
|
|
|
|
.endunion
|
|
|
|
.union
|
|
|
|
r8 .word
|
|
|
|
.struct
|
|
|
|
r8L .byte
|
|
|
|
r8H .byte
|
|
|
|
.endstruct
|
|
|
|
.endunion
|
|
|
|
.union
|
|
|
|
r9 .word
|
|
|
|
.struct
|
|
|
|
r9L .byte
|
|
|
|
r9H .byte
|
|
|
|
.endstruct
|
|
|
|
.endunion
|
|
|
|
.union
|
|
|
|
r10 .word
|
|
|
|
.struct
|
|
|
|
r10L .byte
|
|
|
|
r10H .byte
|
|
|
|
.endstruct
|
|
|
|
.endunion
|
|
|
|
.union
|
|
|
|
r11 .word
|
|
|
|
.struct
|
|
|
|
r11L .byte
|
|
|
|
r11H .byte
|
|
|
|
.endstruct
|
|
|
|
.endunion
|
|
|
|
.union
|
|
|
|
r12 .word
|
|
|
|
.struct
|
|
|
|
r12L .byte
|
|
|
|
r12H .byte
|
|
|
|
.endstruct
|
|
|
|
.endunion
|
|
|
|
.union
|
|
|
|
r13 .word
|
|
|
|
.struct
|
|
|
|
r13L .byte
|
|
|
|
r13H .byte
|
|
|
|
.endstruct
|
|
|
|
.endunion
|
|
|
|
.union
|
|
|
|
r14 .word
|
|
|
|
.struct
|
|
|
|
r14L .byte
|
|
|
|
r14H .byte
|
|
|
|
.endstruct
|
|
|
|
.endunion
|
|
|
|
.union
|
|
|
|
r15 .word
|
|
|
|
.struct
|
|
|
|
r15L .byte
|
|
|
|
r15H .byte
|
|
|
|
.endstruct
|
|
|
|
.endunion
|
|
|
|
.endstruct
|
|
|
|
|
2019-09-27 07:38:51 +00:00
|
|
|
; Kernal
|
2019-11-16 18:11:40 +00:00
|
|
|
FNAM := $84 ; Pointer to filename
|
|
|
|
KTEMP2 := $86 ; 2 bytes for temporary storage
|
2019-12-25 15:56:32 +00:00
|
|
|
IMPARM := $88 ; Pointer for PRIMM function
|
|
|
|
SCREEN_PTR := $90 ; Pointer to current row on text screen (16 bits)
|
2019-11-16 18:11:40 +00:00
|
|
|
|
|
|
|
; BASIC
|
|
|
|
TXTPTR := $EE ; Pointer into BASIC source code
|
2019-09-27 07:38:51 +00:00
|
|
|
|
|
|
|
; Page two
|
|
|
|
|
2019-11-16 18:11:40 +00:00
|
|
|
BASIC_BUF := $0200 ; Location of command-line
|
|
|
|
BASIC_BUF_LEN = 81 ; Maximum length of command-line
|
2019-09-27 07:38:51 +00:00
|
|
|
|
2019-12-25 15:56:32 +00:00
|
|
|
STATUS := $0275 ; Status from previous I/O operation
|
|
|
|
IN_DEV := $0279 ; Current input device number
|
|
|
|
OUT_DEV := $027A ; Current output device number
|
|
|
|
FNAM_LEN := $027D ; Length of filename
|
|
|
|
SECADR := $027F ; Secondary address
|
|
|
|
DEVNUM := $0280 ; Device number
|
|
|
|
CURS_COLOR := $0373 ; Color under the cursor
|
|
|
|
CHARCOLOR := $0377 ; Cursor's color nybbles (high: background, low: foreground)
|
|
|
|
RVS := $0378 ; Reverse flag
|
|
|
|
CURS_FLAG := $037C ; 1 = cursor off
|
|
|
|
CURS_BLINK := $037D ; Blink counter
|
|
|
|
CURS_CHAR := $037E ; Character under the cursor
|
|
|
|
CURS_STATE := $037F ; Cursor blink state
|
|
|
|
CURS_X := $0381 ; Cursor column
|
|
|
|
CURS_Y := $0384 ; Cursor row
|
|
|
|
LLEN := $0387 ; Line length
|
|
|
|
NLINES := $0388 ; Number of screen lines
|
2019-11-16 18:11:40 +00:00
|
|
|
|
|
|
|
; BASIC
|
2019-12-25 15:56:32 +00:00
|
|
|
VARTAB := $03E3 ; Pointer to start of BASIC variables
|
|
|
|
MEMSIZE := $03EB ; Pointer to highest BASIC RAM location (+1)
|
2019-09-27 07:38:51 +00:00
|
|
|
|
|
|
|
; ---------------------------------------------------------------------------
|
|
|
|
; Vector and other locations
|
|
|
|
|
|
|
|
IRQVec := $0314
|
|
|
|
BRKVec := $0316
|
|
|
|
NMIVec := $0318
|
|
|
|
|
|
|
|
; ---------------------------------------------------------------------------
|
|
|
|
; I/O locations
|
|
|
|
|
|
|
|
; Video Enhanced Retro Adapter
|
|
|
|
; Has audio, SPI, and UART.
|
|
|
|
.scope VERA
|
|
|
|
; External registers
|
|
|
|
.struct
|
|
|
|
.org $9F20
|
|
|
|
ADDR .faraddr ; Address for data port access
|
|
|
|
DATA0 .byte ; First data port
|
|
|
|
DATA1 .byte ; Second data port
|
|
|
|
CTRL .byte ; Control register
|
|
|
|
IRQ_EN .byte ; Interrupt enable bits
|
|
|
|
IRQ_FLAGS .byte ; Interrupt flags
|
|
|
|
.endstruct
|
|
|
|
.enum ; Address automatic increment amounts
|
|
|
|
INC0 = 0 << 4
|
|
|
|
INC1 = 1 << 4
|
|
|
|
INC2 = 2 << 4
|
|
|
|
INC4 = 3 << 4
|
|
|
|
INC8 = 4 << 4
|
|
|
|
INC16 = 5 << 4
|
|
|
|
INC32 = 6 << 4
|
|
|
|
INC64 = 7 << 4
|
|
|
|
INC128 = 8 << 4
|
|
|
|
INC256 = 9 << 4
|
|
|
|
INC512 = 10 << 4
|
|
|
|
INC1024 = 11 << 4
|
|
|
|
INC2048 = 12 << 4
|
|
|
|
INC4096 = 13 << 4
|
|
|
|
INC8192 = 14 << 4
|
|
|
|
INC16384 = 15 << 4
|
|
|
|
.endenum
|
2019-11-16 18:11:40 +00:00
|
|
|
.enum ; Interrupt request flags
|
|
|
|
VERT_SYNC = %00000001
|
|
|
|
RASTER = %00000010
|
|
|
|
SPR_COLLIDED = %00000100
|
|
|
|
UART_IRQ = %00001000
|
|
|
|
.endenum
|
2019-12-25 15:56:32 +00:00
|
|
|
|
2019-09-27 07:38:51 +00:00
|
|
|
; Internal RAM and registers
|
2019-12-25 15:56:32 +00:00
|
|
|
|
|
|
|
.struct
|
|
|
|
.org $000000
|
|
|
|
VRAM .res $020000 ; 128 Kibibytes
|
|
|
|
.endstruct
|
2019-09-27 07:38:51 +00:00
|
|
|
.scope COMPOSER ; Display composer
|
|
|
|
.struct
|
|
|
|
.org $0F0000
|
|
|
|
VIDEO .byte
|
|
|
|
HSCALE .byte
|
|
|
|
VSCALE .byte
|
|
|
|
FRAME .byte
|
|
|
|
HSTART_LO .byte
|
|
|
|
HSTOP_LO .byte
|
|
|
|
VSTART_LO .byte
|
|
|
|
VSTOP_LO .byte
|
|
|
|
STRTSTOP_HI .byte
|
|
|
|
IRQ_LINE .word
|
|
|
|
.endstruct
|
|
|
|
.enum MODE ; Output mode
|
|
|
|
DISABLE = 0
|
|
|
|
VGA
|
|
|
|
NTSC
|
|
|
|
RGB ; Interlaced, composite sync
|
|
|
|
.endenum
|
|
|
|
.enum
|
|
|
|
ENABLE_COLOR = 0 << 2
|
|
|
|
DISABLE_COLOR = 1 << 2 ; NTSC monochrome
|
|
|
|
.endenum
|
|
|
|
.endscope
|
|
|
|
PALETTE := $0F1000
|
|
|
|
.struct L0 ; Layer 0 registers
|
|
|
|
.org $0F2000
|
|
|
|
CTRL0 .byte ; Display mode control
|
|
|
|
CTRL1 .byte ; Geometry control
|
|
|
|
MAP_BASE .addr
|
|
|
|
TILE_BASE .addr
|
|
|
|
HSCROLL .word ; Horizontal scroll
|
|
|
|
VSCROLL .word ; Vertical scroll
|
|
|
|
.endstruct
|
|
|
|
.struct L1 ; Layer 1 registers (same as layer 0)
|
|
|
|
.org $0F3000
|
|
|
|
CTRL0 .byte
|
|
|
|
CTRL1 .byte
|
|
|
|
MAP_BASE .addr
|
|
|
|
TILE_BASE .addr
|
|
|
|
HSCROLL .word
|
|
|
|
VSCROLL .word
|
|
|
|
.endstruct
|
|
|
|
.enum MAP ; Map geometry
|
|
|
|
WIDTH32 = 0
|
|
|
|
WIDTH64
|
|
|
|
WIDTH128
|
|
|
|
WIDTH256
|
|
|
|
HEIGHT32 = 0 << 2
|
|
|
|
HEIGHT64 = 1 << 2
|
|
|
|
HEIGHT128 = 2 << 2
|
|
|
|
HEIGHT256 = 3 << 2
|
|
|
|
.endenum
|
|
|
|
.scope TILE ; Tile geometry
|
|
|
|
.enum
|
|
|
|
WIDTH8 = 0 << 4
|
|
|
|
WIDTH16 = 1 << 4
|
|
|
|
WIDTH320 = WIDTH8
|
|
|
|
WIDTH640 = WIDTH16
|
|
|
|
HEIGHT8 = 0 << 5
|
|
|
|
HEIGHT16 = 1 << 5
|
|
|
|
.endenum
|
|
|
|
.enum FLIP
|
|
|
|
NONE = 0 << 2
|
|
|
|
HORIZ = 1 << 2
|
|
|
|
VERT = 2 << 2
|
|
|
|
BOTH = 3 << 2
|
|
|
|
.endenum
|
|
|
|
.endscope
|
|
|
|
.enum DMODE ; Display modes
|
|
|
|
TEXT16 = 0 << 5
|
|
|
|
TEXT256 = 1 << 5
|
|
|
|
TILE4 = 2 << 5
|
|
|
|
TILE16 = 3 << 5
|
|
|
|
TILE256 = 4 << 5
|
|
|
|
BITMAP4 = 5 << 5
|
|
|
|
BITMAP16 = 6 << 5
|
|
|
|
BITMAP256 = 7 << 5
|
|
|
|
.endenum
|
|
|
|
.scope SPRITE
|
|
|
|
.struct
|
|
|
|
.org $0F4000
|
2019-12-25 15:56:32 +00:00
|
|
|
CTRL .byte ; Enables sprite engine
|
2019-09-27 07:38:51 +00:00
|
|
|
COLLISION .byte
|
|
|
|
.endstruct
|
2019-12-25 15:56:32 +00:00
|
|
|
.struct ATTRIB ; Sprite attributes
|
|
|
|
.org $0F5000
|
|
|
|
ADDR .addr ; Address and color mode
|
|
|
|
XX .word
|
|
|
|
YY .word
|
|
|
|
Z_FLIP .byte
|
|
|
|
SIZE_PAL .byte
|
|
|
|
.endstruct
|
2019-09-27 07:38:51 +00:00
|
|
|
.enum FLIP
|
|
|
|
NONE = 0
|
|
|
|
HORIZ
|
|
|
|
VERT
|
|
|
|
BOTH
|
|
|
|
.endenum
|
2019-12-25 15:56:32 +00:00
|
|
|
.enum DEPTH
|
|
|
|
DISABLE = 0 << 2
|
|
|
|
CANVAS = 1 << 2
|
|
|
|
LAYER0 = 2 << 2
|
|
|
|
LAYER1 = 3 << 2
|
|
|
|
.endenum
|
2019-09-27 07:38:51 +00:00
|
|
|
.enum ; Sprite geometry
|
|
|
|
WIDTH8 = 0 << 4
|
|
|
|
WIDTH16 = 1 << 4
|
|
|
|
WIDTH32 = 2 << 4
|
|
|
|
WIDTH64 = 3 << 4
|
|
|
|
HEIGHT8 = 0 << 6
|
|
|
|
HEIGHT16 = 1 << 6
|
|
|
|
HEIGHT32 = 2 << 6
|
|
|
|
HEIGHT64 = 3 << 6
|
|
|
|
COLORS16 = 0 << 7
|
|
|
|
COLORS256 = 1 << 7
|
|
|
|
.endenum
|
|
|
|
.endscope
|
|
|
|
AUDIO := $0F6000
|
|
|
|
.scope SPI
|
|
|
|
.struct
|
|
|
|
.org $0F7000
|
|
|
|
DATA .byte
|
|
|
|
CONTROL .byte
|
|
|
|
.endstruct
|
|
|
|
.enum
|
|
|
|
DESELECT = 0
|
|
|
|
SELECT
|
|
|
|
BUSY_MASK = 1 << 1
|
|
|
|
.endenum
|
|
|
|
.endscope
|
|
|
|
.scope UART ; Universal Asyncronous Receiver Transmitter
|
|
|
|
.struct
|
|
|
|
.org $0F8000
|
|
|
|
DATA .byte
|
|
|
|
STATUS .byte
|
|
|
|
BPS_DIV .word
|
|
|
|
.endstruct
|
|
|
|
.enum MASK
|
|
|
|
RECEIVE = 1 << 0
|
|
|
|
TRANSMIT = 1 << 1
|
|
|
|
.endenum
|
|
|
|
.endscope
|
|
|
|
.endscope
|
|
|
|
|
2019-11-16 18:11:40 +00:00
|
|
|
; 65C22
|
2019-09-27 07:38:51 +00:00
|
|
|
.struct VIA1 ; Versatile Interface Adapter
|
|
|
|
.org $9F60
|
|
|
|
PRB .byte ; ROM bank, IEC (Port Register B)
|
|
|
|
PRA .byte ; RAM bank (Port Register A)
|
|
|
|
DDRB .byte ; (Data Direction Register B)
|
|
|
|
DDRA .byte ; (Data Direction Register A)
|
|
|
|
T1 .word ; (Timer 1)
|
|
|
|
T1L .word ; (Timer 1 Latch)
|
|
|
|
T2 .word ; (Timer 2)
|
|
|
|
SR .byte ; (Shift Register)
|
|
|
|
ACR .byte ; (Auxiliary Control Register)
|
|
|
|
PCR .byte ; (Peripheral Control Register)
|
|
|
|
IFR .byte ; (Interrupt Flags Register)
|
|
|
|
IER .byte ; (Interrupt Enable Register)
|
|
|
|
PRA2 .byte ; RAM bank (Port Register A without handshaking)
|
|
|
|
.endstruct
|
|
|
|
|
2019-11-16 18:11:40 +00:00
|
|
|
; 65C22
|
2019-09-27 07:38:51 +00:00
|
|
|
.struct VIA2
|
|
|
|
.org $9F70
|
2019-11-16 18:11:40 +00:00
|
|
|
PRB .byte ; Mouse communication ?
|
2019-10-15 16:10:34 +00:00
|
|
|
PRA .byte ; NES controller communication
|
2019-09-27 07:38:51 +00:00
|
|
|
DDRB .byte
|
|
|
|
DDRA .byte
|
|
|
|
T1 .word
|
|
|
|
T1L .word
|
|
|
|
T2 .word
|
|
|
|
SR .byte
|
|
|
|
ACR .byte
|
|
|
|
PCR .byte
|
|
|
|
IFR .byte
|
|
|
|
IER .byte
|
|
|
|
PRA2 .byte
|
|
|
|
.endstruct
|
|
|
|
|
|
|
|
; Real-Time Clock
|
|
|
|
|
|
|
|
; X16 Emulator device
|
|
|
|
; This device doesn't exist on the real machine.
|
|
|
|
.struct EMULATOR
|
|
|
|
.org $9FB0
|
|
|
|
DEBUG .byte ; Boolean: debugging enabled
|
2019-10-15 16:10:34 +00:00
|
|
|
VERALOG .byte ; Boolean: log VERA activity
|
2019-09-27 07:38:51 +00:00
|
|
|
KEYBOARDLOG .byte ; Boolean: log keyboard data
|
2019-10-15 16:10:34 +00:00
|
|
|
ECHO .byte ; Type of echo that's enabled
|
2019-09-27 07:38:51 +00:00
|
|
|
SAVEXIT .byte ; Boolean: save on exit
|
2019-10-15 16:10:34 +00:00
|
|
|
GIFREC .byte ; Method of recording GIF movie
|
|
|
|
.org $9FBD
|
|
|
|
KEYMAP .byte ; Current keyboard layout number (Read-Only)
|
|
|
|
DETECT .byte 2 ; If is "16" string, then running on emulator (RO)
|
2019-09-27 07:38:51 +00:00
|
|
|
.endstruct
|
2019-12-25 15:56:32 +00:00
|
|
|
|
|
|
|
; ---------------------------------------------------------------------------
|
|
|
|
; Banked RAM and ROM
|
|
|
|
|
|
|
|
KEY_COUNT := $A00A ; (bank 0) Number of keys in input buffer
|
|
|
|
TIMER := $A03E ; (bank 0) 60 Hz. timer (3 bytes, big-endian)
|
|
|
|
|
|
|
|
.struct BANK
|
|
|
|
.org $A000
|
|
|
|
RAM .res $2000 ; 8 Kibibyte window into 512 Kibibytes or 2048 Kibibytes
|
|
|
|
ROM .res $4000 ; 16 Kibibyte window into 128 Kibibytes
|
|
|
|
.endstruct
|