Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions cli/minimal/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# **************************************************************************************
#
# Very minimal makefile.
#
# **************************************************************************************

#
# Path / Name of emulator.
#
EMULATOR = emu_linux_x64
#
# 64tass optios.
#
ASMOPTS = -b -w -x

#
# Assemble the source
#
assemble:
64tass test.asm $(ASMOPTS) -otest.xex -Ltest.lst
#
# Run program without break.
#
run: assemble
$(EMULATOR) -q file=test.xex

#
# Run program and break on 65816 NOP ($EA)
#
runbrk: assemble
$(EMULATOR) -q file=test.xex break=EA
38 changes: 38 additions & 0 deletions cli/minimal/test.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
; **************************************************************************************
;
; The worlds most simple test program.
;
; **************************************************************************************

.autsiz ; generate code based on last REP/SEP
;
; Start code at $200 (e.g. above zero page and stack)
;
ProgramStart = $200

* = ProgramStart-6
.word $FFFF ; first word of XEX file
.word ProgramStart ; first byte to copy
.word ProgramEnd-1 ; last byte to copy

;
; This is the main code block.
;
nop ; so we can test the breakpoint.
clc ; switch to 65816 mode
xce
rep #$30 ; 16 bit AXY
dec a ; A will be $FFFF hence 16 bit.
ldx #$ABCD

h1: jmp h1

ProgramEnd:

;
; The vector block follows, loaded into $FFE0 ... $FFFF
;
.word $FFE0
.word $FFFF
.word 0, 0, 0, 0, 0, 0, 0, 0
.word 0, 0, 0, 0, 0, 0, ProgramStart, 0
31 changes: 31 additions & 0 deletions cli/text/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# **************************************************************************************
#
# Very minimal makefile.
#
# **************************************************************************************

#
# Path / Name of emulator.
#
EMULATOR = emu_linux_x64
#
# 64tass optios.
#
ASMOPTS = -b -w -x

#
# Assemble the source
#
assemble:
64tass text.asm $(ASMOPTS) -otext.xex -Ltext.lst
#
# Run program without break.
#
run: assemble
x65emu -q file=text.xex

#
# Run program and break on 65816 NOP ($EA)
#
runbrk: assemble
x65emu -q file=text.xex break=EA
97 changes: 97 additions & 0 deletions cli/text/os816/cgia.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
.define CGIA_COLUMN_PX 8

.define CGIA_DL_MODE_BIT %00001000
.define CGIA_DL_DLI_BIT %10000000

.define CGIA_PLANE_REGS_NO 16

.struct CGIA_PLANE_REGS
regs .byte CGIA_PLANE_REGS_NO
.endstruct

.define CGIA_PLANES 4
.define CGIA_AFFINE_FRACTIONAL_BITS 8
.define CGIA_MAX_DL_INSTR 32

.define PLANE_MASK_TRANSPARENT %00000001
.define PLANE_MASK_BORDER_TRANSPARENT %00001000
.define PLANE_MASK_DOUBLE_WIDTH %00010000

.struct CGIA_PLANE_FG
flags .byte
border_columns .byte
row_height .byte
stride .byte
scroll_x .byte
offset_x .byte
scroll_y .byte
offset_y .byte
shared_color0 .byte
shared_color1 .byte
.endstruct

.struct CGIA_PWM
freq .word
duty .byte
.byte
.endstruct

.define CGIA_PWMS 2

.struct CGIA
.org $FF00

mode .byte
bckgnd_bank .byte
sprite_bank .byte
.byte (16-3) ; reserved

raster .word
.byte (6) ; reserved
int_raster .word
int_enable .byte
int_status .byte
.byte (4) ; reserved

pwm0 .tag CGIA_PWM
pwm1 .tag CGIA_PWM
.tag CGIA_PWM ; reserved
.tag CGIA_PWM ; reserved

planes .byte ; [TTTTEEEE] EEEE - enable bits, TTTT - type (0 bckgnd, 1 sprite)
back_color .byte
.byte (8-2) ; reserved
offset0 .word ; // DisplayList or SpriteDescriptor table start
offset1 .word
offset2 .word
offset3 .word
plane0 .tag CGIA_PLANE_REGS
plane1 .tag CGIA_PLANE_REGS
plane2 .tag CGIA_PLANE_REGS
plane3 .tag CGIA_PLANE_REGS
.endstruct

.define CGIA_REG_INT_FLAG_VBI %10000000
.define CGIA_REG_INT_FLAG_DLI %01000000
.define CGIA_REG_INT_FLAG_RSI %00100000

text_mode_fg_color = 150; // 0x96
text_mode_bg_color = 145; // 0x91

CGIA_DL_IN_EMPTY_LINE = $00
CGIA_DL_IN_DUPL_LINE = $01
CGIA_DL_IN_JUMP = $02
CGIA_DL_IN_LOAD_SCAN = $03
CGIA_DL_IN_LMS = %00010000
CGIA_DL_IN_LFS = %00100000
CGIA_DL_IN_LBS = %01000000
CGIA_DL_IN_LCG = %10000000
CGIA_DL_IN_VBL = %10000000

CGIA_DL_IN_MODE2 = $0A
CGIA_DL_IN_MODE3 = $0B
CGIA_DL_IN_MODE4 = $0C
CGIA_DL_IN_MODE5 = $0D
CGIA_DL_IN_MODE6 = $0E
CGIA_DL_IN_MODE7 = $0F

98 changes: 98 additions & 0 deletions cli/text/os816/dspl.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
; Display initialisation
;
; This assumes CIO is ready and S: is after init
;
.export dspl_init

.include "hw/cgia.inc"
.include "hw/ria.inc"

.include "macros.inc"

.segment "DISPLAY"
.org $2000
dspl_text_buffer:
dspl_fg_buffer = dspl_text_buffer + $1000
dspl_bg_buffer = dspl_fg_buffer + $0800
dspl_chargen = dspl_text_buffer + $0800
.reloc

dspl_buffer_width = 48
dspl_buffer_height = 30
dspl_buffer_size = dspl_buffer_width * dspl_buffer_height

.segment "RODATA"
dspl_display_list:
.byte CGIA_DL_IN_LOAD_SCAN | CGIA_DL_IN_LMS|CGIA_DL_IN_LFS|CGIA_DL_IN_LBS|CGIA_DL_IN_LCG
.addr dspl_text_buffer
.addr dspl_fg_buffer
.addr dspl_bg_buffer
.addr dspl_chargen
.res 30, CGIA_DL_IN_MODE2
.byte CGIA_DL_IN_JUMP | CGIA_DL_IN_VBL
.addr dspl_display_list

.code
.a16
.i16
dspl_init:
; initialize CGIA
stz CGIA::mode
stz CGIA::planes
; clear all CGIA registers
ldx #CGIA::mode
ldy #CGIA::mode+2
lda #.sizeof(CGIA) - 3
mvn 0,0

; set initial buffer values
stz dspl_text_buffer
_a8
lda #text_mode_fg_color
sta dspl_fg_buffer
lda #text_mode_bg_color
sta dspl_bg_buffer

; fetch character generator from RIA firmware
phb
pla
sta RIA::stack ; bank address
lda #>dspl_chargen ; high byte
sta RIA::stack
lda #<dspl_chargen ; low byte
sta RIA::stack
lda #RIA_API_GET_CHARGEN
sta RIA::op

_a16
; clear character memory
ldx #dspl_text_buffer
ldy #dspl_text_buffer+2
lda #dspl_buffer_size - 3
mvn 0,0
; fill foreground memory
ldx #dspl_fg_buffer
ldy #dspl_fg_buffer+1
lda #dspl_buffer_size - 2
mvn 0,0
; fill background memory
ldx #dspl_bg_buffer
ldy #dspl_bg_buffer+1
lda #dspl_buffer_size - 2
mvn 0,0

; set display list offset
lda #dspl_display_list
sta CGIA::offset0
_a8
; set row height to 8 pixels
lda #7
sta CGIA::plane0+CGIA_PLANE_FG::row_height
; and finally enable the plane
lda #%00000001
sta CGIA::planes
_a16

; TODO: Setup S: to use values configured above

rts
96 changes: 96 additions & 0 deletions cli/text/os816/ria.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
.struct RIA
.org $FFC0

; math accelerator
opera .word
operb .word
mulab .word
divab .word

; monotonic clock
tm .byte 6
_tm_res .byte 2

; DMA
addr_src .faraddr
step_src .byte
addr_dst .faraddr
step_dst .byte
count .byte
dma_err .byte

; file access
fda .byte
fda_rw .byte
fdb .byte
fdb_rw .byte
_fd_res .byte 2

; UART
uart_rdy .byte
uart_rxtx .byte

; Random Number Generator
rng .word

; CPU Vectors Native
cop_n .addr
brk_n .addr
abort_n .addr
nmi_n .addr

; Interrupt Control
irq_status .byte
irq_enable .byte

; CPU Vector Native
irq_n .addr

; RIA816 API
stack .byte
op .byte
errno .byte
busy .byte

; CPU Vector Emulation
cop_e .addr

; Extension devices
extio .byte
extmem .byte

; CPU Vector Emulation
abort_e .addr
nmi_e .addr
reset_e .addr
irq_brk_e .addr
.endstruct

.struct TIMERS
.org $FF88
; CIA compatible timers
ta_lo .byte
ta_hi .byte
tb_lo .byte
tb_hi .byte
_t_res .byte
icr .byte
cra .byte
crb .byte
.endstruct

.struct GPIO
.org $FF80
; GPIO ports
in0 .byte
in1 .byte
out0 .byte
out1 .byte
pol0 .byte
pol1 .byte
cfg0 .byte
cfg1 .byte
.endstruct

RIA_API_HALT = $FF
RIA_API_GET_CHARGEN = $10
Loading