Style changes.

This commit is contained in:
Greg King 2015-10-02 10:50:22 -04:00 committed by Oliver Schmidt
parent 203200e259
commit b5d939c858
23 changed files with 142 additions and 159 deletions

View File

@ -9,7 +9,7 @@ charsperline = 61
CH_HLINE = 1
CH_VLINE = 2
; huc6270 - Video Display Controller (VDC)
; HuC6270 - Video Display Controller (VDC)
VDC_MAWR = 0 ; Memory Address Write Register
VDC_MARR = 1 ; Memory Address Read Register
@ -42,21 +42,21 @@ VDC_CTRL := $0200
VDC_DATA_LO := $0202
VDC_DATA_HI := $0203
; huc6260 - Video Color Encoder (vce)
; HuC6260 - Video Color Encoder (vce)
; The DAC has a palette of 512 colours.
; bitmap of the palette data is this: 0000000gggrrrbbb.
; You can read and write the DAC-registers.
; The bitmap of the palette data is this: 0000000gggrrrbbb.
; You can read and write the DAC registers.
VCE = $0400 ; base
VCE_CTRL = $0400 ; write$00 to reset
VCE_CTRL = $0400 ; write $00 to reset
VCE_ADDR_LO = $0402 ; LSB of byte offset into palette
VCE_ADDR_HI = $0403 ; MSB of byte offset into palette
VCE_DATA_LO = $0404 ; LSB of 16-bit palette data
VCE_DATA_HI = $0405 ; MSB of 16-bit palette data
; programmable sound generator (PSG)
; Programmable Sound Generator (PSG)
PSG = $0800 ; base
@ -71,12 +71,12 @@ PSG_NOISE = $0807
PSG_LFO_FREQ = $0808
PSG_LFO_CTRL = $0809
; timer
; Timer
TIMER = $0c00 ; base
TIMER = $0C00 ; base
TIMER_COUNT = $0c00
TIMER_CTRL = $0c01
TIMER_COUNT = $0C00
TIMER_CTRL = $0C01
JOY_CTRL = $1000

View File

@ -1,4 +1,4 @@
# linker config. to produce a NEC PC-Engine 8K, 16K, or 32K image (.bin)
# Linker config. to produce a NEC PC-Engine 8K, 16K, or 32K image (.bin)
SYMBOLS {
__CARTSIZE__: type = weak, value = $2000; # $2000, $4000, or $8000
__STACKSIZE__: type = weak, value = $0300; # 3 pages stack

View File

@ -2,10 +2,10 @@
<article>
<title>PC-Engine (TurboGrafx) System specific information for cc65
<title>PC-Engine (TurboGrafx 16) System-specific information for cc65
<author><url url="mailto:groepaz@gmx.net" name="Groepaz/Hitmen">,<newline>
<url url="mailto:greg.king5@verizon.net" name="Greg King">
<date>2018-02-12
<date>2018-02-24
<abstract>
An overview over the PCE runtime system as it is implemented for the
@ -20,12 +20,12 @@ cc65 C compiler.
<sect>Overview<p>
This file contains an overview of the PCE runtime system as it comes
with the cc65 C compiler. It describes the memory layout, PCE specific header
with the cc65 C compiler. It describes the memory layout, PCE-specific header
files, available drivers, and any pitfalls specific to that platform.
Please note that PCE specific functions are just mentioned here, they are
described in detail in the separate <url url="funcref.html" name="function
reference">. Even functions marked as "platform dependent" may be available on
Please note that PCE-specific functions are just mentioned here; they are
described, in detail, in the separate <url url="funcref.html" name="function
reference">. Even functions marked as "platform dependent" might be available on
more than one platform. Please see the function reference for more
information.
@ -63,7 +63,7 @@ actually see when they execute the code in that cartridge.
<sect>Memory layout<p>
cc65 generated programs with the default setup run with the I/O area and a
cc65-generated programs with the default setup run with the I/O area and a
CHR bank enabled, which gives a usable memory range of &dollar;8000 - &dollar;FFF3.
All boot ROM entry points may be called directly without additional code.
@ -71,11 +71,11 @@ Special locations:
<descrip>
<tag/Text screen and Font/
The text screen is located at VRAM &dollar;0000,
The text screen is located at VRAM &dollar;0000;
the Font is located at VRAM &dollar;2000.
<tag/Stack/
The C runtime stack is located in system RAM at &dollar;3FFF and growing downwards.
The C runtime stack is located in system RAM at &dollar;3FFF; and, grows downwards.
<tag/Data and BSS/
The Data (initialized variables) and BSS (uninitialized variables) sections are
@ -98,12 +98,12 @@ Special locations:
<sect>Platform specific header files<p>
<sect>Platform-specific header files<p>
Programs containing PCE specific code may use the <tt/pce.h/ header file.
Programs containing PCE-specific code may use the <tt/pce.h/ header file.
<sect1>PCE specific functions<p>
<sect1>PCE-specific functions<p>
<itemize>
<item>waitvsync</item>
@ -111,11 +111,10 @@ Programs containing PCE specific code may use the <tt/pce.h/ header file.
</itemize>
<sect1>Hardware access<p>
The following pseudo variables declared in the <tt/pce.inc/ include file do
allow access to hardware located in the address space.
The following pseudo variables, declared in the <tt/pce.inc/ include file, do
allow access to hardware that is located in the address space.
<descrip>
@ -153,9 +152,9 @@ No extended memory drivers are currently available for the PCE.
<descrip>
<tag><tt/pce-stdjoy.joy (pce_stdjoy)/</tag>
A joystick driver for the standard two buttons joypad is available.
A joystick driver for the standard two-button joypad is available.
Note that the japanese 6-button pad is currently not supported.
Note that the Japanese 6-button pad currently is not supported.
</descrip><p>
@ -177,6 +176,7 @@ No serial drivers are currently available for the PCE.
<item>interruptor support in crt0 (and cfg) is missing
</itemize>
<sect1>Disk I/O<p>
The existing library for the PCE doesn't implement C file
@ -197,6 +197,8 @@ following functions (and a few others):
<item>...
</itemize>
<sect>Other hints<p>
<itemize>
@ -204,7 +206,7 @@ following functions (and a few others):
emulator to use for the PC-Engine.
</itemize>
some useful resources on PCE coding:
Some useful resources on PCE coding:
<itemize>
<item><url url="http://blog.blockos.org/?tag=pc-engine">
@ -218,9 +220,11 @@ some useful resources on PCE coding:
<item><url url="http://www.zeograd.com/parse.php?src=hucf">
</itemize>
<sect>License<p>
This software is provided 'as-is', without any expressed or implied
This software is provided "as-is", without any expressed or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
@ -229,14 +233,14 @@ including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
<enum>
<item> The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
<item> Altered source versions must be plainly marked as such, and must not
be misrepresented as being the original software.
<item> This notice may not be removed or altered from any source
distribution.
<item>The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated, but is not required.
<item>Altered source versions must be marked plainly as such; and, must not
be misrepresented as being the original software.
<item>This notice may not be removed or altered from any source
distribution.
</enum>
</article>

View File

@ -2,11 +2,11 @@
/* */
/* pce.h */
/* */
/* PC-Engine system specific definitions */
/* PC-Engine system-specific definitions */
/* */
/* */
/* */
/* (C) 2015 Groepaz/Hitmen */
/* (C) 2015, Groepaz/Hitmen */
/* */
/* */
/* This software is provided 'as-is', without any expressed or implied */
@ -51,7 +51,7 @@
#define CH_ENTER 13
#define CH_PI 18
/* Color defines (CBM compatible, for conio) */
/* Color defines (CBM-compatible, for conio) */
#define COLOR_BLACK 0x00
#define COLOR_WHITE 0x01
#define COLOR_RED 0x02
@ -102,7 +102,7 @@ extern void pce_stdjoy_joy[]; /* Referred to by joy_static_stddrv[] */
void waitvsync (void);
/* Wait for start of the next frame */
/* NOTE: all PCE are NTSC */
/* NOTE: all PCEs are NTSC. */
#define get_tv() TV_NTSC
/* Return the video mode the machine is using. */

View File

@ -1,9 +1,11 @@
;
; Screen size variables
;
.export screensize
.export xsize, ysize
.include "pce.inc"
.export screensize
screensize:
ldx xsize
ldy ysize
@ -12,7 +14,6 @@ screensize:
; FIXME: changing the video mode allows for different screen sizes
.rodata
.export xsize, ysize
xsize: .byte charsperline
ysize: .byte screenrows

View File

@ -6,6 +6,7 @@
;
.export _chlinexy, _chline
.import gotoxy, cputdirect
.importzp tmp1
@ -25,7 +26,3 @@ L1: lda #CH_HLINE ; Horizontal line, screen code
dec tmp1
bne L1
L9: rts

View File

@ -2,17 +2,15 @@
; clock_t clock (void);
;
.include "pce.inc"
.include "extzp.inc"
.export _clock
.constructor initclock, 24
.forceimport ticktock
.importzp sreg
.constructor initclock
.include "extzp.inc"
.proc _clock
lda tickcount+3
sta sreg+1
lda tickcount+2
@ -20,7 +18,6 @@
ldx tickcount+1
lda tickcount
rts
.endproc
.segment "ONCE"

View File

@ -1,11 +1,11 @@
.export _clrscr
.import plot
.include "pce.inc"
.include "extzp.inc"
.import plot
.export _clrscr
_clrscr:
st0 #VDC_MAWR
st1 #<$0000
st2 #>$0000

View File

@ -4,14 +4,15 @@
; unsigned char __fastcall__ bordercolor (unsigned char color);
;
.export _textcolor, _bgcolor, _bordercolor
.export colors
.import return0
.include "pce.inc"
.include "extzp.inc"
_bordercolor = return0
_bordercolor := return0
_textcolor:
ldx CHARCOLOR ; get old value
@ -35,27 +36,25 @@ _bgcolor:
txa
rts
.rodata
.export colors
.rodata
colors:
; G R B
.word ((0<<6)+(0<<3)+(0)) ; 0 black
.word ((7<<6)+(7<<3)+(7)) ; 1 white
.word ((0<<6)+(7<<3)+(0)) ; 2 red
.word ((7<<6)+(0<<3)+(7)) ; 3 cyan
.word ((0<<6)+(5<<3)+(7)) ; 4 violett
.word ((7<<6)+(0<<3)+(0)) ; 5 green
.word ((0<<6)+(0<<3)+(7)) ; 6 blue
.word ((7<<6)+(7<<3)+(0)) ; 7 yellow
.word ((5<<6)+(7<<3)+(0)) ; 8 orange
.word ((3<<6)+(4<<3)+(3)) ; 9 brown
.word ((4<<6)+(7<<3)+(4)) ; a light red
.word ((3<<6)+(3<<3)+(3)) ; b dark grey
.word ((4<<6)+(4<<3)+(4)) ; c middle grey
.word ((7<<6)+(4<<3)+(4)) ; d light green
.word ((4<<6)+(4<<3)+(7)) ; e light blue
.word ((6<<6)+(6<<3)+(6)) ; f light gray
; G R B
colors: .word ((0<<6)+(0<<3)+(0)) ; $0 black
.word ((7<<6)+(7<<3)+(7)) ; $1 white
.word ((0<<6)+(7<<3)+(0)) ; $2 red
.word ((7<<6)+(0<<3)+(7)) ; $3 cyan
.word ((0<<6)+(5<<3)+(7)) ; $4 violett
.word ((7<<6)+(0<<3)+(0)) ; $5 green
.word ((0<<6)+(0<<3)+(7)) ; $6 blue
.word ((7<<6)+(7<<3)+(0)) ; $7 yellow
.word ((5<<6)+(7<<3)+(0)) ; $8 orange
.word ((3<<6)+(4<<3)+(3)) ; $9 brown
.word ((4<<6)+(7<<3)+(4)) ; $A light red
.word ((3<<6)+(3<<3)+(3)) ; $B dark grey
.word ((4<<6)+(4<<3)+(4)) ; $C middle grey
.word ((7<<6)+(4<<3)+(4)) ; $D light green
.word ((4<<6)+(4<<3)+(7)) ; $E light blue
.word ((6<<6)+(6<<3)+(6)) ; $F light gray
;-------------------------------------------------------------------------------
; force the init constructor to be imported

View File

@ -1,13 +1,13 @@
.include "pce.inc"
.include "extzp.inc"
.constructor initconio, 24
.import vce_init
.import psg_init
.import vdc_init
.import colors
.importzp ptr1, tmp1
.constructor initconio
.include "pce.inc"
.include "extzp.inc"
.macpack longbranch
.segment "ONCE"
@ -39,7 +39,7 @@ set_palette:
inx
inx
cpx #16*2
cpx #16 * 2
jne @lp
stz VCE_ADDR_LO
@ -72,7 +72,7 @@ conio_init:
lda #>font
sta ptr1+1
lda #$ff
lda #$FF
sta tmp1
jsr copy
@ -113,5 +113,5 @@ fillloop:
rts
font:
.include "vga.inc"
.rodata
font: .include "vga.inc"

View File

@ -5,11 +5,11 @@
.export _cputcxy, _cputc, cputdirect, putchar
.export newline, plot
.import gotoxy
.import PLOT
.import xsize
.importzp tmp3,tmp4
.importzp tmp3, tmp4
.include "pce.inc"
.include "extzp.inc"
@ -21,13 +21,13 @@ _cputcxy:
; Plot a character - also used as internal function
_cputc: cmp #$0d ; CR?
_cputc: cmp #$0D ; CR?
bne L1
lda #0
sta CURS_X
beq plot ; Recalculate pointers
L1: cmp #$0a ; LF?
L1: cmp #$0A ; LF?
beq newline ; Recalculate pointers
; Printable char of some sort
@ -43,7 +43,7 @@ advance:
cpy xsize
bne L3
jsr newline ; new line
ldy #0 ; + cr
ldy #0 ; + CR
L3: sty CURS_X
jmp plot
@ -71,7 +71,7 @@ putchar:
lda SCREEN_PTR
sta VDC_DATA_LO
lda SCREEN_PTR + 1
lda SCREEN_PTR+1
sta VDC_DATA_HI
st0 #VDC_VWR ; VWR

View File

@ -1,8 +1,8 @@
;
; Startup code for cc65 (PCEngine version)
;
; by Groepaz/Hitmen <groepaz@gmx.net>
; based on code by Ullrich von Bassewitz <uz@cc65.org>
; by Groepaz/Hitmen <groepaz@gmx.net>,
; based on code by Ullrich von Bassewitz <uz@cc65.org>.
;
; 2018-02-11, Greg King
;
@ -28,16 +28,12 @@
; ------------------------------------------------------------------------
; Place the startup code in a special segment.
.segment "STARTUP"
start:
; Set up the CPU and System-IRQ
.segment "STARTUP"
; Initialize CPU
sei
start: sei
nop
csh ; Set high speed CPU mode
csh ; Set high-speed CPU mode
nop
; Set up stack and memory mapping
@ -64,7 +60,7 @@ start:
inc a
@L1: tam #%01000000 ; $C000-$DFFF = ROM bank 3 (32K) or 1 (16K)
;lda #$00 ; (The reset default)
;tam #%10000000 ; $E000-$FFFF hucard/syscard bank 0
;tam #%10000000 ; $E000-$FFFF Hucard/Syscard bank 0
; Initialize hardware
stz TIMER_CTRL ; Timer off
@ -72,7 +68,7 @@ start:
sta IRQ_MASK ; Interrupts off
stz IRQ_STATUS ; Acknowledge timer
; FIXME; i dont know why the heck this one doesnt work when called from a constructor :/
; FIXME; I don't know why the heck this one doesn't work when called from a constructor. :/
.import vdc_init
jsr vdc_init
@ -96,24 +92,22 @@ start:
; Call module constructors
jsr initlib
cli ; allow IRQ only after constructors have run
cli ; allow IRQ only after constructors have run
; Pass an empty command line
jsr push0 ; argc
jsr push0 ; argv
ldy #4 ; Argument size
jsr _main ; Call the users code
jsr _main ; Call the user's code
; Call module destructors. This is also the _exit entry.
_exit:
jsr donelib ; Run module destructors
_exit: jsr donelib ; Run module destructors
; reset the PCEngine (start over)
jmp start
_nmi:
rti
_nmi: rti
.export initmainargs
initmainargs:
@ -122,10 +116,10 @@ initmainargs:
; ------------------------------------------------------------------------
; hardware vectors
; ------------------------------------------------------------------------
.segment "VECTORS"
.segment "VECTORS"
.word IRQStub ; $fff6 IRQ2 (External IRQ, BRK)
.word IRQStub ; $fff8 IRQ1 (VDC)
.word IRQStub ; $fffa Timer
.word _nmi ; $fffc NMI
.word start ; $fffe reset
.word IRQStub ; $FFF6 IRQ2 (External IRQ, BRK)
.word IRQStub ; $FFF8 IRQ1 (VDC)
.word IRQStub ; $FFFA Timer
.word _nmi ; $FFFC NMI
.word start ; $FFFE reset

View File

@ -10,7 +10,7 @@
.rodata
; The following 256 byte wide table specifies attributes for the isxxx type
; The following 256-byte-wide table specifies attributes for the isxxx type
; of functions. Doing it by a table means some overhead in space, but it
; has major advantages:
;
@ -157,5 +157,3 @@ __ctype:
.byte CT_NONE ; 126/7e _____~_____
.byte CT_OTHER_WS ; 127/7f ____DEL____
.endrepeat

View File

@ -6,6 +6,7 @@
;
.export _cvlinexy, _cvline
.import gotoxy, putchar, newline
.importzp tmp1
@ -26,6 +27,3 @@ L1: lda #CH_VLINE ; Vertical bar
dec tmp1
bne L1
L9: rts

View File

@ -4,15 +4,15 @@
; zeropage locations for exclusive use by the library
;
.include "extzp.inc"
.include "extzp.inc"
.segment "EXTZP" : zeropage
.segment "EXTZP" : zeropage
CURS_X: .res 1
CURS_Y: .res 1
SCREEN_PTR: .res 2
CHARCOLOR: .res 1
RVS: .res 1
BGCOLOR: .res 1
tickcount: .res 4
vdc_flags: .res 1
CURS_X: .res 1
CURS_Y: .res 1
SCREEN_PTR: .res 2
CHARCOLOR: .res 1
RVS: .res 1
BGCOLOR: .res 1
tickcount: .res 4
vdc_flags: .res 1

View File

@ -3,6 +3,7 @@
;
.export gotoxy, _gotoxy
.import popa, plot
.include "pce.inc"

View File

@ -1,4 +1,3 @@
;
; Standard joystick driver for the PCEngine
;
@ -17,8 +16,8 @@
; Driver signature
.byte $6A, $6F, $79 ; "joy"
.byte JOY_API_VERSION ; Driver API version number
.byte $6A, $6F, $79 ; "joy"
.byte JOY_API_VERSION ; Driver API version number
; Library reference
@ -43,7 +42,7 @@ JOY_COUNT = 4 ; Number of joysticks we support
; INSTALL routine. Is called after the driver is loaded into memory. If
; possible, check if the hardware is present and determine the amount of
; memory available.
; Must return an JOY_ERR_xx code in a/x.
; Must return a JOY_ERR_xx code in a/x.
;
INSTALL:
@ -90,7 +89,7 @@ joy1:
rts
read_joy:
; reset multitap counter
; Reset Multitap counter.
lda #$01
sta JOY_CTRL
pha
@ -108,7 +107,7 @@ read_joy:
cly
nextpad:
lda #$01
sta JOY_CTRL ; sel = 1
sta JOY_CTRL ; sel = 1
pha
pla
nop ; some delay is required
@ -119,21 +118,20 @@ nextpad:
asl a
asl a
asl a
sta padbuffer, y ; store new value
sta padbuffer,y ; store new value
stz JOY_CTRL
pha
pla
nop ; some delay is required
nop
lda JOY_CTRL
and #$0F
ora padbuffer, y ; second half of new value
ora padbuffer,y ; second half of new value
eor #$FF
sta padbuffer, y ; store new value
sta padbuffer,y ; store new value
iny
cpy #$05
@ -144,4 +142,3 @@ nextpad:
padbuffer:
.res 4

View File

@ -20,7 +20,7 @@ PLOT:
ldy CURS_X
rts
.rodata
.rodata
_plotlo:
.repeat screenrows,line

View File

@ -1,7 +1,7 @@
.include "pce.inc"
.export psg_init
.include "pce.inc"
.segment "ONCE"
psg_init:
clx

View File

@ -1,11 +1,10 @@
.export _revers
.include "pce.inc"
.include "extzp.inc"
.export _revers
.proc _revers
ldx #$00 ; Assume revers off
tay ; Test onoff
beq L1 ; Jump if off
@ -18,7 +17,6 @@ L1: lda RVS ; Load old value
L2: ldx #$00 ; Load high byte of result
tya ; Load low byte, set CC
rts
.endproc
;-------------------------------------------------------------------------------

View File

@ -1,7 +1,7 @@
.include "pce.inc"
.export vce_init
.include "pce.inc"
.segment "ONCE"
vce_init:
; Set CTA to zero

View File

@ -1,11 +1,11 @@
.export vdc_init
.include "pce.inc"
; FIXME: implement selection of different video modes at runtime
HIRES = 1
.export vdc_init
vdc_init:
lda VDC_CTRL

View File

@ -4,17 +4,16 @@
; void waitvsync (void);
;
.export _waitvsync
.forceimport ticktock
.include "pce.inc"
.include "extzp.inc"
.forceimport ticktock
.export _waitvsync
.proc _waitvsync
lda tickcount
@lp: cmp tickcount
beq @lp
rts
.endproc