mirror of
https://github.com/michaelcmartin/Ophis.git
synced 2024-11-08 07:04:39 +00:00
Basic platform headers.
* C64, NES, and Atari 2600 ("Stella") useful constants headers. * crt0.s equivalent for C64. * Hello World for the C64.
This commit is contained in:
parent
14a37ca879
commit
feba267ee7
60
platform/c64/c64_0.oph
Normal file
60
platform/c64/c64_0.oph
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
;;
|
||||||
|
;; Commodore 64 Basic Runtime File
|
||||||
|
;;
|
||||||
|
;; Include this at the TOP of your C64 program, and it will handle
|
||||||
|
;; hiding away the BASIC ROM and data and restoring it at the end.
|
||||||
|
;;
|
||||||
|
;; You will have a contiguous block of RAM from $0800 to $CF81, and
|
||||||
|
;; Zero Page access from $02 to $7F in the segment "zp".
|
||||||
|
|
||||||
|
.word $0801
|
||||||
|
.org $0801
|
||||||
|
|
||||||
|
; BASIC program that just calls our machine language code
|
||||||
|
.scope
|
||||||
|
.word _next, 10 ; Next line and current line number
|
||||||
|
.byte $9e," 2062",0 ; SYS 2062
|
||||||
|
_next: .word 0 ; End of program
|
||||||
|
.scend
|
||||||
|
|
||||||
|
.data zp ; Zero Page memory segment.
|
||||||
|
.org $0002
|
||||||
|
|
||||||
|
.text
|
||||||
|
|
||||||
|
.scope
|
||||||
|
; Cache BASIC zero page at top of available RAM
|
||||||
|
ldx #$7E
|
||||||
|
* lda $01, x
|
||||||
|
sta $CF81, x
|
||||||
|
dex
|
||||||
|
bne -
|
||||||
|
|
||||||
|
; Swap out the BASIC ROM for RAM
|
||||||
|
lda $01
|
||||||
|
and #$fe
|
||||||
|
ora #$06
|
||||||
|
sta $01
|
||||||
|
|
||||||
|
; Run the real program
|
||||||
|
jsr _main
|
||||||
|
|
||||||
|
; Restore BASIC ROM
|
||||||
|
lda $01
|
||||||
|
ora #$07
|
||||||
|
sta $01
|
||||||
|
|
||||||
|
; Restore BASIC zero page
|
||||||
|
ldx #$7E
|
||||||
|
* lda $CF81, x
|
||||||
|
sta $01, x
|
||||||
|
dex
|
||||||
|
bne -
|
||||||
|
|
||||||
|
; Back to BASIC
|
||||||
|
rts
|
||||||
|
|
||||||
|
_main:
|
||||||
|
; Program follows...
|
||||||
|
.scend
|
67
platform/c64/c64kernal.oph
Normal file
67
platform/c64/c64kernal.oph
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
; KERNAL routine aliases (C64)
|
||||||
|
|
||||||
|
.alias acptr $ffa5
|
||||||
|
.alias chkin $ffc6
|
||||||
|
.alias chkout $ffc9
|
||||||
|
.alias chrin $ffcf
|
||||||
|
.alias chrout $ffd2
|
||||||
|
.alias ciout $ffa8
|
||||||
|
.alias cint $ff81
|
||||||
|
.alias clall $ffe7
|
||||||
|
.alias close $ffc3
|
||||||
|
.alias clrchn $ffcc
|
||||||
|
.alias getin $ffe4
|
||||||
|
.alias iobase $fff3
|
||||||
|
.alias ioinit $ff84
|
||||||
|
.alias listen $ffb1
|
||||||
|
.alias load $ffd5
|
||||||
|
.alias membot $ff9c
|
||||||
|
.alias memtop $ff99
|
||||||
|
.alias open $ffc0
|
||||||
|
.alias plot $fff0
|
||||||
|
.alias ramtas $ff87
|
||||||
|
.alias rdtim $ffde
|
||||||
|
.alias readst $ffb7
|
||||||
|
.alias restor $ff8a
|
||||||
|
.alias save $ffd8
|
||||||
|
.alias scnkey $ff9f
|
||||||
|
.alias screen $ffed
|
||||||
|
.alias second $ff93
|
||||||
|
.alias setlfs $ffba
|
||||||
|
.alias setmsg $ff90
|
||||||
|
.alias setnam $ffbd
|
||||||
|
.alias settim $ffdb
|
||||||
|
.alias settmo $ffa2
|
||||||
|
.alias stop $ffe1
|
||||||
|
.alias talk $ffb4
|
||||||
|
.alias tksa $ff96
|
||||||
|
.alias udtim $ffea
|
||||||
|
.alias unlsn $ffae
|
||||||
|
.alias untlk $ffab
|
||||||
|
.alias vector $ff8d
|
||||||
|
|
||||||
|
; Character codes for the colors.
|
||||||
|
.alias color'0 144
|
||||||
|
.alias color'1 5
|
||||||
|
.alias color'2 28
|
||||||
|
.alias color'3 159
|
||||||
|
.alias color'4 156
|
||||||
|
.alias color'5 30
|
||||||
|
.alias color'6 31
|
||||||
|
.alias color'7 158
|
||||||
|
.alias color'8 129
|
||||||
|
.alias color'9 149
|
||||||
|
.alias color'10 150
|
||||||
|
.alias color'11 151
|
||||||
|
.alias color'12 152
|
||||||
|
.alias color'13 153
|
||||||
|
.alias color'14 154
|
||||||
|
.alias color'15 155
|
||||||
|
|
||||||
|
; ...and reverse video
|
||||||
|
.alias reverse'on 18
|
||||||
|
.alias reverse'off 146
|
||||||
|
|
||||||
|
; ...and character set
|
||||||
|
.alias upper'case 142
|
||||||
|
.alias lower'case 14
|
12
platform/c64/demo/c64_hello.oph
Normal file
12
platform/c64/demo/c64_hello.oph
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
.include "../c64_0.oph"
|
||||||
|
.include "../c64kernal.oph"
|
||||||
|
|
||||||
|
ldy #$00
|
||||||
|
* lda text, y
|
||||||
|
beq +
|
||||||
|
jsr chrout
|
||||||
|
iny
|
||||||
|
bne -
|
||||||
|
* rts
|
||||||
|
|
||||||
|
text: .byte "HELLO, C64 WORLD!", 13, 0
|
15
platform/nes/nes.oph
Normal file
15
platform/nes/nes.oph
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
; NES-related headers. Unlike the C64 and Stella developers, there is
|
||||||
|
; no standard nomenclature for these registers. It's not uncommon to
|
||||||
|
; see them hardcoded.
|
||||||
|
|
||||||
|
; PPU registers have reasonably standard names, at least.
|
||||||
|
|
||||||
|
.alias PPUCTRL $2000 ; PPU Control Register #1
|
||||||
|
.alias PPUMASK $2001 ; PPU Control Register #2
|
||||||
|
.alias PPUSTATUS $2002 ; PPU Status Register
|
||||||
|
.alias OAMADDR $2003 ; SPR-RAM Address Register
|
||||||
|
.alias OAMDATA $2004 ; SPR-RAM I/O Register
|
||||||
|
.alias PPUSCROLL $2005 ; VRAM Address Register #1 (Panning control)
|
||||||
|
.alias PPUADDR $2006 ; VRAM Address Register #2 (Direct Address control)
|
||||||
|
.alias PPUDATA $2007 ; VRAM I/O Register
|
||||||
|
.alias OAMDMA $4014 ; Sprite DMA Register
|
127
platform/stella/stella.oph
Normal file
127
platform/stella/stella.oph
Normal file
@ -0,0 +1,127 @@
|
|||||||
|
; Register mnemonics for the Atari 2600 VCS
|
||||||
|
;
|
||||||
|
; Taken from the "Stella Programming Guide", at
|
||||||
|
; http://www.alienbill.com/2600/101/docs/stella.html
|
||||||
|
|
||||||
|
; Writable TIA addresses
|
||||||
|
|
||||||
|
.alias VSYNC $00 ; vertical sync set-clear
|
||||||
|
.alias VBLANK $01 ; vertical blank set-clear
|
||||||
|
.alias WSYNC $02 ; wait for leading edge of horizontal blank
|
||||||
|
.alias RSYNC $03 ; reset horizontal sync counter
|
||||||
|
.alias NUSIZ0 $04 ; number-size player-missile 0
|
||||||
|
.alias NUSIZ1 $05 ; number-size player-missile 1
|
||||||
|
.alias COLUP0 $06 ; color-lum player 0
|
||||||
|
.alias COLUP1 $07 ; color-lum player 1
|
||||||
|
.alias COLUPF $08 ; color-lum playfield
|
||||||
|
.alias COLUBK $09 ; color-lum background
|
||||||
|
.alias CTRLPF $0A ; control playfield ball size and collisions
|
||||||
|
.alias REFP0 $0B ; reflect player 0
|
||||||
|
.alias REFP1 $0C ; reflect player 1
|
||||||
|
.alias PF0 $0D ; playfield register byte 0
|
||||||
|
.alias PF1 $0E ; playfield register byte 1
|
||||||
|
.alias PF2 $0F ; playfield register byte 2
|
||||||
|
.alias RESP0 $10 ; reset player 0
|
||||||
|
.alias RESP1 $11 ; reset player 1
|
||||||
|
.alias RESM0 $12 ; reset missile 0
|
||||||
|
.alias RESM1 $13 ; reset missile 1
|
||||||
|
.alias RESBL $14 ; reset ball
|
||||||
|
.alias AUDC0 $15 ; audio control 0
|
||||||
|
.alias AUDC1 $16 ; audio control 1
|
||||||
|
.alias AUDF0 $17 ; audio frequency 0
|
||||||
|
.alias AUDF1 $18 ; audio frequency 1
|
||||||
|
.alias AUDV0 $19 ; audio volume 0
|
||||||
|
.alias AUDV1 $1A ; audio volume 1
|
||||||
|
.alias GRP0 $1B ; Graphics player 0
|
||||||
|
.alias GRP1 $1C ; Graphics player 1
|
||||||
|
.alias ENAM0 $1D ; Graphics enable missile 0
|
||||||
|
.alias ENAM1 $1E ; Graphics enable missile 1
|
||||||
|
.alias ENABL $1F ; Graphics enable ball
|
||||||
|
.alias HMP0 $20 ; horizontal motion player 0
|
||||||
|
.alias HMP1 $21 ; horizontal motion player 1
|
||||||
|
.alias HMM0 $22 ; horizontal motion missile 0
|
||||||
|
.alias HMM1 $23 ; horizontal motion missile 1
|
||||||
|
.alias HMBL $24 ; horizontal motion ball
|
||||||
|
.alias VDELP0 $25 ; vertical delay player 0
|
||||||
|
.alias VDELP1 $26 ; vertical delay player 1
|
||||||
|
.alias VDELBL $27 ; vertical delay ball
|
||||||
|
.alias RESMP0 $28 ; reset missile 0 to player 0
|
||||||
|
.alias RESMP1 $29 ; reset missile 1 to player 1
|
||||||
|
.alias HMOVE $2A ; apply horizontal motion
|
||||||
|
.alias HMCLR $2B ; clear horizontal motion registers
|
||||||
|
.alias CXCLR $2C ; clear collision latches
|
||||||
|
|
||||||
|
; Readable TIA addresses
|
||||||
|
|
||||||
|
.alias CXM0P $00 ; read collision missile 0 players
|
||||||
|
.alias CXM1P $01 ; read collision missile 1 players
|
||||||
|
.alias CXP0FB $02 ; read collision player 0 playfield/ball
|
||||||
|
.alias CXP1FB $03 ; read collision player 1 playfield/ball
|
||||||
|
.alias CXM0FB $04 ; read collision missile 0 playfield/ball
|
||||||
|
.alias CXM1FB $05 ; read collision missile 1 playfield/ball
|
||||||
|
.alias CXBLPF $06 ; read collision ball playfield
|
||||||
|
.alias CXPPMM $07 ; read collision player/player missile/missile
|
||||||
|
.alias INPT0 $08 ; read pot port
|
||||||
|
.alias INPT1 $09 ; read pot port
|
||||||
|
.alias INPT2 $0A ; read pot port
|
||||||
|
.alias INPT3 $0B ; read pot port
|
||||||
|
.alias INPT4 $0C ; read input
|
||||||
|
.alias INPT5 $0D ; read input
|
||||||
|
|
||||||
|
; PIA addresses
|
||||||
|
|
||||||
|
.alias SWCHA $280 ; Port A data register (read/write)
|
||||||
|
.alias SWACNT $281 ; Port A data direction register (0=input, 1=output)
|
||||||
|
.alias SWCHB $282 ; Port B - console switches (read-only)
|
||||||
|
.alias SWBCNT $283 ; Port B data direction register (hardwired to 0)
|
||||||
|
.alias INTIM $284 ; Timer output (read only)
|
||||||
|
.alias TIM1T $294 ; Set 1-clock interval (838 nsec/interval)
|
||||||
|
.alias TIM8T $295 ; Set 8-clock interval (6.7 usec/interval)
|
||||||
|
.alias TIM64T $296 ; Set 64-clock interval (53.6 usec/interval
|
||||||
|
.alias T1024T $297 ; Set 1025-clock interval (858.2 usec/interval)
|
||||||
|
|
||||||
|
; These macros are adapted from DASM's old macro.h. Credit and description are
|
||||||
|
; replicated from there.
|
||||||
|
|
||||||
|
;-------------------------------------------------------------------------------
|
||||||
|
; VERTICAL_SYNC
|
||||||
|
; Original author: Manuel Polik
|
||||||
|
; Inserts the code required for a proper 3 scanline
|
||||||
|
; vertical sync sequence
|
||||||
|
;
|
||||||
|
; Note: Alters the accumulator
|
||||||
|
;
|
||||||
|
; IN:
|
||||||
|
; OUT: A = 1
|
||||||
|
|
||||||
|
.macro vertical'sync
|
||||||
|
lda #$02
|
||||||
|
sta WSYNC
|
||||||
|
sta VSYNC
|
||||||
|
sta WSYNC
|
||||||
|
sta WSYNC
|
||||||
|
lsr
|
||||||
|
sta WSYNC
|
||||||
|
sta VSYNC
|
||||||
|
.macend
|
||||||
|
|
||||||
|
;-------------------------------------------------------------------------------
|
||||||
|
; CLEAN_START
|
||||||
|
; Original author: Andrew Davie
|
||||||
|
; Standardised start-up code, clears stack, all TIA registers and RAM to 0
|
||||||
|
; Sets stack pointer to $FF, and all registers to 0
|
||||||
|
; Sets decimal mode off, sets interrupt flag (kind of un-necessary)
|
||||||
|
; Use as very first section of code on boot (ie: at reset)
|
||||||
|
; Code written to minimise total ROM usage - uses weird 6502 knowledge :)
|
||||||
|
.macro clean'start
|
||||||
|
sei
|
||||||
|
cld
|
||||||
|
ldx #$00
|
||||||
|
txa
|
||||||
|
tay
|
||||||
|
_clear'stack:
|
||||||
|
dex
|
||||||
|
txs
|
||||||
|
pha
|
||||||
|
bne _clear'stack
|
||||||
|
.macend
|
Loading…
Reference in New Issue
Block a user