Skip to content

Commit

Permalink
add cbm example
Browse files Browse the repository at this point in the history
  • Loading branch information
yeastplume committed Sep 24, 2021
1 parent e8dd6a9 commit 6523310
Show file tree
Hide file tree
Showing 8 changed files with 144 additions and 0 deletions.
7 changes: 7 additions & 0 deletions samples_cbm/Makefile.vars
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Common emulator flags and locations
# Ensure the emulator and rom locations are for your system

ALOEVERA = "../../target/debug/aloevera"
C128_EMU = x128
C128_EMU_FLAGS =
#DEBUG = -debug 9000
36 changes: 36 additions & 0 deletions samples_cbm/common/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Common makefile include for examples
# Don't run make from this directory, run
# from subdirs

C128_RUN = $(C128_EMU) $(C128_EMU_FLAGS) $(DEBUG)

# Ensure ld65 and ca65 are on your path
# Assembly flags
CPU = 6502
AS = ca65
# Add defines, if needed (-DWHATEVER)
ASFLAGS = -g --cpu $(CPU)

# Linker flags
LD = ld65
#Define segments and files in config.cfg
LDFLAGS = -C ../common/c128-asm.cfg

OBJS_$(NAME): $(NAME).o
$(LD) $(LDFLAGS) -o $(NAME).prg -m $(NAME).map $(NAME).o

$(NAME).o: project.av $(NAME).s
$(AS) $(ASFLAGS) $(NAME).s

run_fresh:
$(C128_RUN)

run_asm: OBJS_$(NAME)
$(C128_RUN) -autostart $(NAME).prg

run_bas: $(NAME).assembled.bas
$(C128_RUN) -bas $(NAME).assembled.bas

all: OBJS_$(NAME)
clean:
rm -rf ./output *.o *.prg *.map *.av *.log *.assembled.bas *.img *.BIN *.meta
17 changes: 17 additions & 0 deletions samples_cbm/common/c128-asm.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FEATURES {
STARTADDRESS: default = $1C00;
}
MEMORY {
ZP: file = "", start = $0002, size = $00FE, define = yes;
LOADADDR: file = %O, start = %S - 2, size = $0002;
MAIN: file = %O, start = %S, size = $D000 - %S;
}
SEGMENTS {
ZEROPAGE: load = ZP, type = zp, optional = yes;
LOADADDR: load = LOADADDR, type = ro;
EXEHDR: load = MAIN, type = ro, optional = yes;
CODE: load = MAIN, type = rw;
RODATA: load = MAIN, type = ro, optional = yes;
DATA: load = MAIN, type = rw, optional = yes;
BSS: load = MAIN, type = bss, optional = yes, define = yes;
}
9 changes: 9 additions & 0 deletions samples_cbm/common/header.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
;Basic Header
.segment "LOADADDR"
.word $1C01

.segment "EXEHDR"
.word next, 10
.byte $9e, "7188", 0, 0
.word 0, 0, 0
next: .word 0
45 changes: 45 additions & 0 deletions samples_cbm/common/macros.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
; adds a constant to 16 bit value
; stored at addr
.macro add_constant_16 addr, constant
clc
lda addr
adc #<constant
sta addr
lda addr + 1
adc #>constant
sta addr + 1
.endmacro

; loop until value stored in addr equals constant
.macro loop_till_eq_16 addr, constant, loop_label
lda addr+1
cmp #>constant ;loop until 512 reached
bne loop_label
lda addr
cmp #<constant
bne loop_label
.endmacro

; set a 16 bit constant in addr
.macro set_const_16 addr, constant
lda #<constant
sta addr
lda #>constant
sta addr+1
.endmacro

VERA_ADDR_LO = $9F20
VERA_ADDR_MID = VERA_ADDR_LO + 1;
VERA_ADDR_HI = VERA_ADDR_LO + 2;
VERA_DATA0 = VERA_ADDR_LO + 3;
VERA_DATA1 = VERA_ADDR_LO + 4;

.macro v_address_set addr, stride
lda #<(addr >> 16) | stride << 4
sta VERA_ADDR_HI
lda #<(addr >> 8)
sta VERA_ADDR_MID
lda #<(addr)
sta VERA_ADDR_LO
.endmacro

19 changes: 19 additions & 0 deletions samples_cbm/petscii_tile/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
include ../Makefile.vars
NAME = p128

project.av: p128-ref-template.png
$(ALOEVERA) create project project.av
$(ALOEVERA) -p project.av palette import cbm_palette p128-ref-template.png
# $(ALOEVERA) -p project.gx16 imageset import text_set_1 8 8 pixel-font.png
# $(ALOEVERA) -p project.gx16 imageset format text_set_1 palette_1 1
# $(ALOEVERA) -p project.gx16 asm ./output/ all
$(ALOEVERA) -p project.av asm -f ca65 ./output/ all

generate_resources: project.av

generate_basic: generate_resources
cat $(NAME).bas > $(NAME).assembled.bas

$(NAME).assembled.bas: generate_basic

include ../common/Makefile
Binary file added samples_cbm/petscii_tile/p128-ref-template.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions samples_cbm/petscii_tile/p128.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.include "../common/header.inc"

.code
lda #$00
sta $d020
sta $d021
rts

.segment "RODATA"
imageset:
.include "output/palettes/cbm_palette.ca65.inc"

0 comments on commit 6523310

Please sign in to comment.