diff --git a/presets/astrocade/acbios.h b/presets/astrocade/acbios.h index b042fe4e..23463ac6 100644 --- a/presets/astrocade/acbios.h +++ b/presets/astrocade/acbios.h @@ -31,12 +31,22 @@ const FontDescriptor __at(0x20d) FNTSML; #define OPT_ON(n) ((n)<<2) #define OPT_OFF(n) ((n)) +#define DISBCD_SML 0x40 +#define DISBCD_NOZERO 0x80 + void activate_interrupts(void); -void wait_for_vsync(void); +void sleep(byte frames) __z88dk_fastcall; void display_string(byte x, byte y, byte options, const char* str); void paint_rectangle(byte x, byte y, byte w, byte h, byte colormask); -void write_relative(byte x, byte y, byte magic, const char* pattern); +void blank_area(byte wb, byte h, byte data, byte* video); + +void write_relative(byte x, byte y, byte magic, const byte* pattern); +void write_pattern(byte x, byte y, byte magic, const byte* pattern); + +void display_bcd_number(byte x, byte y, byte options, const byte* number, byte extopt); +void bcdn_add(byte* dest, byte size, const byte* n); +void bcdn_sub(byte* dest, byte size, const byte* n); // QUICK MACROS diff --git a/presets/astrocade/acbios.s b/presets/astrocade/acbios.s index f189f763..d64e73b2 100644 --- a/presets/astrocade/acbios.s +++ b/presets/astrocade/acbios.s @@ -1,400 +1,6 @@ -; ****** HVGLIB.H (formally called ballyequ.h) (C)1977,78 -; *** Bally Astrocade Equates and Macros Header File *** -; From the nutting_manual and reformatted using Mixed Case -; Version 3.01 - thru December 29, 2010 -; by Richard C Degler, from scratch -; -; > Retyped and proofread by Adam Trionfo and Lance F. Squire -; > Version 1.0 (as ballyequ.h) - January 17, 2002 -; > Version 2.52 (Version 1.0 of HVGLIB.H) - March 28, 2003 -; > Version 2.6 - March 2, 2004 - as seen on BallyAlley.com -; > Version 3.0 - 2009 -; > Version 3.01 - Changed "FonT BASE character" comment -; > -; > This file contains the equates and macros that Bally -; > programs require for assembly. This file has been -; > written to assemble with ZMAC 1.3 (a freely distribut- -; > able Z-80 assembler (with C source), that has a 25-year -; > history. ZMAC can be compiled under just about any O.S. -; > in existence, so try it out. This file will probably -; > require changes to be assembled under other assemblers. -; > -; > To assemble your Z-80 source code using ZMAC: -; > -; > zmac -d -o -x -; > -; > For example, assemble this Astrocade Z-80 ROM file: -; > -; > zmac -d -o BallyROM.bin -x BallyROM.lst BallyROM.asm -; > -; > Currently the Listing file is full of 'Undeclared' -; > errors. When all of the source is typed-in, these will -; > vanish. I'm leaving the others until all the source is -; > re-typed. -; > -; -; *************************** -; * Home Video Game =ates * -; *************************** -; -; ASSEMBLY CONTROL -; -XPNDON = 1 ; ** SET TO 1 WHEN HARDWARE EXP -NWHDWR = 1 ; ** SET TO 1 WHEN NEW HARDWARE -; -; General goodies (HEX and Decimal values): -NORMEM = 0x4000 ; 8192 ; NORmal MEMory start -FIRSTC = 0x2000 ; 4096 ; FIRST address in Cartridge -SCREEN = 0x0000 ; 0 ; magic SCREEN start -BYTEPL = 0x28 ; 40 ; BYTEs Per Line -BITSPL = 0xA0 ; 160 ; BITS Per Line -; -; Stuff in SYSTEM DOPE VECTOR (valid for ALL system ROMs): -STIMER = 0x0200 ; Seconds and game TIMER, music -CTIMER = 0x0203 ; Custom TIMERs -FNTSYS = 0x0206 ; FoNT descriptor for SYStem font -FNTSML = 0x020D ; FoNT descriptor for SMaLl font -ALKEYS = 0x0214 ; ALl KEYS keypad mask -MENUST = 0x0218 ; head of onboard MENU STart -MXSCR = 0x021E ; address of 'MaX SCoRe' text string -NOPLAY = 0x0228 ; address of 'Number Of PLAYers' string -NOGAME = 0x0235 ; address of 'Number Of GAMEs' string -; -; BITS in PROCESSOR FLAG byte: -PSWCY = 0 ; Processor Status Word, CarrY bit -PSWPV = 2 ; Processor Status Word, Parity or oVerflow bit -PSWZRO = 6 ; Processor Status Word, ZeRO bit -PSWSGN = 7 ; Processor Status Word, SiGN bit -; -; BITS in GAME STATUS Byte: -GSBTIM = 0 ; Game Status Byte, if TIMe is up set end bit -GSBSCR = 1 ; Game Status Byte, if SCoRe reached set end bit -GSBEND = 7 ; Game Status Byte, END flag bit -; -; Standard VECTOR DISPLACEMENTS and bits: -VBMR = 0x00 ; +0 ; Vector Block, Magic Register -VBSTAT = 0x01 ; +1 ; Vector Block, STATus byte -VBTIMB = 0x02 ; +2 ; Vector Block, TIMe Base -VBDXL = 0x03 ; +3 ; Vector Block, Delta for X Low -VBDXH = 0x04 ; +4 ; Vector Block, Delta for X Hi -VBXL = 0x05 ; +5 ; Vector Block, X coord Low -VBXH = 0x06 ; +6 ; Vector Block, X coord Hi -VBXCHK = 0x07 ; +7 ; Vector Block, X CHecK flags -VBDYL = 0x08 ; +8 ; Vector Block, Delta for Y Low -VBDYH = 0x09 ; +9 ; Vector Block, Delta for Y Hi -VBYL = 0x0A ; +10 ; Vector Block, Y coord Low -VBYH = 0x0B ; +11 ; Vector Block, Y coord Hi -VBYCHK = 0x0C ; +12 ; Vector Block, Y CHecK flags -VBOAL = 0x0D ; +13 ; Vector Block, Old Address Low -VBOAH = 0x0E ; +14 ; Vector Block, Old Address Hi -; -; DISPLACEMENTS from start of COORDINATE AREA (X or Y): -VBDCL = 0x00 ; +0 ; Vector Block, Delta for Coord Low -VBDCH = 0x01 ; +1 ; Vector Block, Delta for Coord Hi -VBCL = 0x02 ; +2 ; Vector Block, Coord Low -VBCH = 0x03 ; +3 ; Vector Block, Coord Hi -VBCCHK = 0x04 ; +4 ; Vector Block, Coord CHecK flags -; -; BITS in STATUS byte: -VBBLNK = 6 ; Vector Block status, BLaNK bit -VBSACT = 7 ; Vector Block Status, ACTive bit -; -; BITS in (X or Y) VB CHECK FLAG bit mask: -VBCLMT = 0 ; Vector Block Check, LiMiT bit -VBCREV = 1 ; Vector Block Check, REVerse delta on limit attain -VBCLAT = 3 ; Vector Block Check, coordinate Limit ATtained -; -; FONT TABLE DISPLACEMENTS for CHARACTER DESCRIPTOR BLOCK: -FTBASE = 0x00 ; +0 ; FonT BASE character (normally 0xA0) -FTFSX = 0x01 ; +1 ; FonT Frame X Size width -FTFSY = 0x02 ; +2 ; FonT Frame Y Size height -FTBYTE = 0x03 ; +3 ; FonT X size for char in BYTEs -FTYSIZ = 0x04 ; +4 ; FonT Y SIZe height in rows -FTPTL = 0x05 ; +5 ; FonT Pattern Table address Low -FTPTH = 0x06 ; +6 ; FonT Pattern Table address Hi -; -; BITS for MAGIC REGISTER (write option) byte: -MRSHFT = 0x03 ; Magic Register, mask of SHiFT amount 0-3 -MRROT = 2 ; Magic Register, write with ROTata bit -MRXPND = 3 ; Magic Register, write with eXPaND bit -MROR = 4 ; Magic Register, write with OR bit -MRXOR = 5 ; Magic Register, write with eXclusive-OR bit -MRFLOP = 6 ; Magic Register, write with FLOP bit -; -; BITS of CONTROL HANDLE Input port: -CHUP = 0 ; Control Handle, UP bit -CHDOWN = 1 ; Control Handle, DOWN bit -CHLEFT = 2 ; Control Handle, joystick LEFT bit -CHRIGH = 3 ; Control Handle, joystick RIGHT bit -CHTRIG = 4 ; Control Handle, TRIGger bit -; -; CONTEXT BLOCK Register DISPLACEMENTS: -CBIYL = 0x00 ; +0 ; Context Block, IY register Low -CBIYH = 0x01 ; +1 ; Context Block, IY register Hi -CBIXL = 0x02 ; +2 ; Context Block, IX register Low -CBIXH = 0x03 ; +3 ; Context Block, IX register Hi -CBE = 0x04 ; +4 ; Context Block, E register -CBD = 0x05 ; +5 ; Context Block, D register -CBC = 0x06 ; +6 ; Context Block, C register -CBB = 0x07 ; +7 ; Context Block, B register -CBFLAG = 0x08 ; +8 ; Context Block, FLAGs register -CBA = 0x09 ; +9 ; Context Block, A register -CBL = 0x0A ; +10 ; Context Block, L register -CBH = 0x0B ; +11 ; Context Block, H register -; -; SENTRY RETURN Codes =ates: -SNUL = 0x00 ; Sentry return NULl, nothing happened -SCT0 = 0x01 ; Sentry, Counter-Timer 0 has counted down -SCT1 = 0x02 ; Sentry, Counter-Timer 1 has counted down -SCT2 = 0x03 ; Sentry, Counter-Timer 2 has counted down -SCT3 = 0x04 ; Sentry, Counter-Timer 3 has counted down -SCT4 = 0x05 ; Sentry, Counter-Timer 4 has counted down -SCT5 = 0x06 ; Sentry, Counter-Timer 5 has counted down -SCT6 = 0x07 ; Sentry, Counter-Timer 6 has counted down -SCT7 = 0x08 ; Sentry, Counter-Timer 7 has counted down -SF0 = 0x09 ; Sentry, Flag bit 0 has changed -SF1 = 0x0A ; Sentry, Flag bit 1 has changed -SF2 = 0x0B ; Sentry, Flag bit 2 has changed -SF3 = 0x0C ; Sentry, Flag bit 3 has changed -SF4 = 0x0D ; Sentry, Flag bit 4 has changed -SF5 = 0x0E ; Sentry, Flag bit 5 has changed -SF6 = 0x0F ; Sentry, Flag bit 6 has changed -SF7 = 0x10 ; Sentry, Flag bit 7 has changed -SSEC = 0x11 ; Sentry, SEConds timer has counted down -SKYU = 0x12 ; Sentry, KeY is now Up -SKYD = 0x13 ; Sentry, KeY is now Down -ST0 = 0x14 ; Sentry, Trigger 0 for player 1 has changed -SJ0 = 0x15 ; Sentry, Joystick 0 for player 1 has changed -ST1 = 0x16 ; Sentry, Trigger 1 for player 2 has changed -SJ1 = 0x17 ; Sentry, Joystick 1 for player 2 has changed -ST2 = 0x18 ; Sentry, Trigger 2 for player 3 has changed -SJ2 = 0x19 ; Sentry, Joystick 2 for player 3 has changed -ST3 = 0x1A ; Sentry, Trigger 3 for player 4 has changed -SJ3 = 0x1B ; Sentry, Joystick 3 for player 4 has changed -SP0 = 0x1C ; Sentry, POTentiometer 0 has changed -SP1 = 0x1D ; Sentry, POTentiometer 1 has changed -SP2 = 0x1E ; Sentry, POTentiometer 2 has changed -SP3 = 0x1F ; Sentry, POTentiometer 3 has changed -; -; -; ******************************** -; * Home Video Game PORT =ates * -; ******************************** -; -; OUTPUT Ports for VIRTUAL COLOR: -COL0R = 0x00 ; &(0)= ; write COLor 0 Right -COL1R = 0x01 ; &(1)= ; write COLor 1 Right -COL2R = 0x02 ; &(2)= ; write COLor 2 Right -COL3R = 0x03 ; &(3)= ; write COLor 3 Right -COL0L = 0x04 ; &(4)= ; write COLor 0 Left -COL1L = 0x05 ; &(5)= ; write COLor 1 Left -COL2L = 0x06 ; &(6)= ; write COLor 2 Left -COL3L = 0x07 ; &(7)= ; write COLor 3 Left -HORCB = 0x09 ; &(9)= ; write HORizontal Color Boundary -VERBL = 0x0A ;&(10)= ; write VERtical Blanking Line -COLBX = 0x0B ;&(11)= ; write COLor BloCK multi-port -; -; OUTPUT Ports for MUSIC and SOUNDS: -TONMO = 0x10 ;&(16)= ; write TONe Master Oscillator -TONEA = 0x11 ;&(17)= ; write TONe A oscillator -TONEB = 0x12 ;&(18)= ; write TONe B oscillator -TONEC = 0x13 ;&(19)= ; write TONe C oscillator -VIBRA = 0x14 ;&(20)= ; write VIBRAto frequency & range -VOLC = 0x15 ;&(21)= ; write VOLume of tone C -VOLAB = 0x16 ;&(22)= ; write VOLumes of tones A & B -VOLN = 0x17 ;&(23)= ; write VOLume of Noise -SNDBX = 0x18 ;&(24)= ; write SouND BloCK multi-port -; -; INTERRUPT and CONTROL OUTPUT Ports: -CONCM = 0x08 ; &(8)= ; write 0 for CONsumer, 1 for CoMmercial mode -MAGIC = 0x0C ;&(12)= ; write MAGIC register -INFBK = 0x0D ;&(13)= ; write INterrupt FeedBacK -INMOD = 0x0E ;&(14)= ; write INterrupt MODe -INLIN = 0x0F ;&(15)= ; write INterrupt LINe -XPAND = 0x19 ;&(25)= ; eXPANDer pixel definition port -; -; INTERRUPT and INTERCEPT INPUT Ports: -INTST = 0x08 ; =&(8) ; read INTercept STatus -VERAF = 0x0E ;=&(14) ; read VERtical Address Feedback -HORAF = 0x0F ;=&(15) ; read HORizontal Address Feedback -; -; HAND CONTROL INPUT Ports: -SW0 = 0x10 ;=&(16) ; read SWitch bank 0 for player 1 hand control -SW1 = 0x11 ;=&(17) ; read SWitch bank 1 for player 2 hand control -SW2 = 0x12 ;=&(18) ; read SWitch bank 2 for player 3 hand control -SW3 = 0x13 ;=&(19) ; read SWitch bank 3 for player 4 hand control -POT0 = 0x1C ;=&(28) ; read POTentiometer 0 for player 1 knob -POT1 = 0x1D ;=&(29) ; read POTentiometer 1 for player 2 knob -POT2 = 0x1E ;=&(30) ; read POTentiometer 2 for player 3 knob -POT3 = 0x1F ;=&(31) ; read POTentiometer 3 for player 4 knob -; -; KEYBOARD INPUT Ports: -KEY0 = 0x14 ;=&(20) ; KEYboard column 0 (right side) -KEY1 = 0x15 ;=&(21) ; KEYboard column 1 (center right) -KEY2 = 0x16 ;=&(22) ; KEYboard column 2 (center left) -KEY3 = 0x17 ;=&(23) ; KEYboard column 3 (left side) -; -; -; *************************************** -; * Home Video Game SYSTEM CALL Indexes * -; *************************************** -; -; USER PROGRAM Interface: -INTPC = 0x00 ; # 0 ; INTerPret with Context create -XINTC = 0x02 ; # 2 ; eXit INTerpreter with Context -RCALL = 0x04 ; # 4 ; Real CALL asm language subroutine -MCALL = 0x06 ; # 6 ; Macro CALL interpreter subroutine -MRET = 0x08 ; # 8 ; Macro RETurn from interpreter subroutine -MJUMP = 0x0A ; # 10 ; Macro JUMP to interpreter subroutine -SUCK = 0x0C ; # 12 ; SUCK inline args into context block -; -; SCHEDULER Routines: -ACTINT = 0x0E ; # 14 ; ACTivate sub timer INTerrupts -DECCTS = 0x10 ; # 16 ; DECrement CT'S under mask -; -; MUSIC and SOUNDS: -BMUSIC = 0x12 ; # 18 ; Begin playing MUSIC -EMUSIC = 0x14 ; # 20 ; End playing MUSIC -; -; SCREEN HANDLER Routines: -SETOUT = 0x16 ; # 22 ; SET some OUTput ports -COLSET = 0x18 ; # 24 ; COLors SET -FILL = 0x1A ; # 26 ; FILL memory with data -RECTAN = 0x1C ; # 28 ; paint a RECTANgle -VWRITR = 0x1E ; # 30 ; Vector WRITe Relative -WRITR = 0x20 ; # 32 ; WRITe Relative -WRITP = 0x22 ; # 34 ; WRITe with Pattern size lookup -WRIT = 0x24 ; # 36 ; WRITe with sizes provided -WRITA = 0x26 ; # 38 ; WRITe Absolute -VBLANK = 0x28 ; # 40 ; Vector BLANK area -BLANK = 0x2A ; # 42 ; BLANK area -SAVE = 0x2C ; # 44 ; SAVE area -RESTOR = 0x2E ; # 46 ; RESTORe area -SCROLL = 0x30 ; # 48 ; SCROLL area of screen -; -CHRDIS = 0x32 ; # 50 ; CHaRacter DISplay -STRDIS = 0x34 ; # 52 ; STRing DISplay -DISNUM = 0x36 ; # 54 ; DISplay NUMber -; -RELABS = 0x38 ; # 56 ; RELative to ABSolute conversion -RELAB1 = 0x3A ; # 58 ; RELative to non-magic ABSolute -VECTC = 0x3C ; # 60 ; VECTor move single Coordinate -VECT = 0x3E ; # 62 ; VECTor move coordinate pair -; -; HUMAN INTERFACE Routines: -KCTASC = 0x40 ; # 64 ; Key Code in B To ASCii -SENTRY = 0x42 ; # 66 ; SENse TRansition Y -DOIT = 0x44 ; # 68 ; DOIT table, branch to translation handler -DOITB = 0x46 ; # 70 ; DOIT table, use B instead of A -PIZBRK = 0x48 ; # 72 ; take a PIZza BReaK -MENU = 0x4A ; # 74 ; display a MENU -GETPAR = 0x4C ; # 76 ; GET game PARameter from user -GETNUM = 0x4E ; # 78 ; GET NUMber from user -PAWS = 0x50 ; # 80 ; PAUSE -DISTIM = 0x52 ; # 82 ; DISplay TIMe -INCSCR = 0x54 ; # 84 ; INCrement SCoRe -; -; MATH Routines: -INDEXN = 0x56 ; # 86 ; INDEX Nibble by C -STOREN = 0x58 ; # 88 ; STORE Nibble in A by C -INDEXW = 0x5A ; # 90 ; INDEX Word by A -INDEXB = 0x5C ; # 92 ; INDEX Byte by A -MOVE = 0x5E ; # 94 ; MOVE block transfer -SHIFTU = 0x60 ; # 96 ; SHIFT Up digit in A -BCDADD = 0x62 ; # 98 ; BCD ADDition -BCDSUB = 0x64 ;# 100 ; BCD SUBtraction -BCDMUL = 0x66 ;# 102 ; BCD MULtiplication -BCDDIV = 0x68 ;# 104 ; BCD DIVision -BCDCHS = 0x6A ;# 106 ; BCD CHange Sign -BCDNEG = 0x6C ;# 108 ; BCD NEGate to decimal -DADD = 0x6E ;# 110 ; Decimal ADDition -DSMG = 0x70 ;# 112 ; Decimal convert to Sign MaGnitude -DABS = 0x72 ;# 114 ; Decimal ABSolute value -NEGT = 0x74 ;# 116 ; decimal NEGaTe -RANGED = 0x76 ;# 118 ; RANGED random number -QUIT = 0x78 ;# 120 ; QUIT cassette execution -SETB = 0x7A ;# 122 ; SET Byte -SETW = 0x7C ;# 124 ; SET Word -MSKTD = 0x7E ;# 127 ; MaSK joystick in B To Deltas -; -; -; *************************** -; * SYSTEM RAM MEMORY Cells * -; *************************** -WASTE = 0x0FFF -WASTER = WASTE -; -SYSRAM = 0x4FCE ; Resides at the highest possible address -BEGRAM = SYSRAM ; typically used for initial Stack Pointer -; Used by MUSIC PROCESSOR: -MUZPC = 0x4FCE ; MUSic Program Counter -MUZSP = 0x4FD0 ; MUSic Stack Pointer -PVOLAB = 0x4FD2 ; Preset VOLume for tones A and B -PVOLMC = 0x4FD3 ; Preset VOLuMe for tone C and Noise Mode -VOICES = 0x4FD4 ; music VOICES mask -; COUNTER TIMERS (used by DECCTS,ACTINT,CTIMER): -CT0 = 0x4FD5 ; Counter Timer 0 -CT1 = 0x4FD6 ; Counter Timer 1 -CT2 = 0x4FD7 ; Counter Timer 2 -CT3 = 0x4FD8 ; Counter Timer 3 -CT4 = 0x4FD9 ; Counter Timer 4 -CT5 = 0x4FDA ; Counter Timer 5 -CT6 = 0x4FDB ; Counter Timer 6 -CT7 = 0x4FDC ; Counter Timer 7 -;Used by SENTRY to track controls: -CNT = 0x4FDD ; Counter update & Number Tracking -SEMI4S = 0x4FDE ; SEMAPHORE flag bitS -OPOT0 = 0x4FDF ; Old POT 0 tracking byte -OPOT1 = 0x4FE0 ; Old POT 1 tracking byte -OPOT2 = 0x4FE1 ; Old POT 2 tracking byte -OPOT3 = 0x4FE2 ; Old POT 3 tracking byte -KEYSEX = 0x4FE3 ; KEYS-EX tracking byte -OSW0 = 0x4FE4 ; Old SWitch 0 tracking byte -OSW1 = 0x4FE5 ; Old SWitch 1 tracking byte -OSW2 = 0x4FE6 ; Old SWitch 2 tracking byte -OSW3 = 0x4FE7 ; Old SWitch 3 tracking byte -COLLST = 0x4FE8 ; COLset LaST address for P.B. A -; Used by STIMER: -DURAT = 0x4FEA ; note DURATion -TMR60 = 0x4FEB ; TiMeR for SIXTY'ths of sec -TIMOUT = 0x4FEC ; TIMer for blackOUT -GTSECS = 0x4FED ; Game Time SECondS -GTMINS = 0x4FEE ; Game Time MINuteS -; Used by MENU: -RANSHT = 0x4FEF ; RANdom number SHifT register -NUMPLY = 0x4FF3 ; NUMber of PLaYers -ENDSCR = 0x4FF4 ; END SCoRe to 'play to' -MRLOCK = 0x4FF7 ; Magic Register LOCK out flag -GAMSTB = 0x4FF8 ; GAMe STatus Byte -PRIOR = 0x4FF9 ; PRIOR music protect flag -SENFLG = 0x4FFA ; SENtry control seizure FLaG -; User UPI Routines, even numbers from 0x80 to 0xFE ( + 1 for SUCK): -UMARGT = 0x4FFB ; User Mask ARGument Table + (routine / 2) -USERTB = 0x4FFD ; USER Table Base + routine = JumP address -; -URINAL = 0x4FFF ; WASTER flushes here! -; -; + .include "astrocade.inc" -; -; MACROs to generate SYSTEM CALLs: - .macro SYSTEM NUMBA - rst 0x38 - .db NUMBA -; .if NUMBA = INTPC -;INTPCC DEFL 1 -; .endif - .endm -; MACRO to generate SYSTEM CALL with SUCK option ON: - .macro SYSSUK UMBA - rst 0x38 - .db UMBA + 1 -; .if UMBA = INTPC -;INTPCC DEFL 1 -; .endif - .endm - ;;; C functions .area CODE @@ -409,59 +15,84 @@ _activate_interrupts: ret ; wait for next interrupt - .globl _wait_for_vsync -_wait_for_vsync: -; this is faster than PAWS - ld hl,#TMR60 - ld a,(hl) -.1: cp a,(hl) - jp z,.1 - ret -; SYSTEM PAWS -; .db 1 + .globl _sleep +_sleep: + ld b,l + SYSTEM PAWS + ret -; build a SYSSUK block on the stack -; <5 bytes> -; rst <5 bytes> ret +; load 5 bytes from stack into registers +load5_edca_hl: + ld ix,#4 + add ix,sp + ld e,0(ix) ; x + ld d,1(ix) ; y + ld c,2(ix) ; options + ld b,c + ld a,c + ld l,3(ix) ; addr lo + ld h,4(ix) ; addr hi + ret + +; STRDIR x y options string-addr .globl _display_string _display_string: - ld h,#(STRDIS+1) -syssuk5: - pop de ; return address - ld l,#0xff ; RST 0x38 - push hl ; SYSSUK - ld iy,#0 - add iy,sp ; SP -> IY - ld ix,#7 - add ix,sp ; SP+7 -> IX - push de ; push return addr - ld e,(ix) ; load what's there - push de ; push it - ld d,#0xc9 ; ret opcode - ld (ix),d ; store after params - ld hl,#endsuk5 - push hl + call load5_edca_hl ld ix,#0x20d ; alternate font desc. - jp (iy) ; jump to RST - -endsuk5: - pop de ; old ret value - pop hl ; return address - ld ix,#7 - add ix,sp ; SP+7 -> IX - ld (ix),e ; restore old ret value - pop de ; get rid of SYSSUK cmd - jp (hl) ; caller takes care of rest + SYSTEM STRDIS + ret ; RECTAN x y w h colormask .globl _paint_rectangle _paint_rectangle: - ld h,#(RECTAN+1) - jp syssuk5 + call load5_edca_hl + ld b,l + ld h,a + SYSTEM RECTAN + ret -; WRITP x y magic pattern +; WRITR x y magic pattern-addr .globl _write_relative _write_relative: - ld h,#(WRITR+1) - jp syssuk5 + call load5_edca_hl + SYSTEM WRITR + ret + +; WRITP x y magic pattern-addr + .globl _write_pattern +_write_pattern: + call load5_edca_hl + SYSTEM WRITP + ret + +; DISNUM x y options number-addr + .globl _display_bcd_number +_display_bcd_number: + call load5_edca_hl + ld b,5(ix) ; addr hi + ld ix,#0x20d ; alternate font desc. + SYSTEM DISNUM + ret + +; BCDADD arg1 size arg2 + .globl _bcdn_add +_bcdn_add: + call load5_edca_hl + ld b,c + SYSTEM BCDADD + ret + +; BCDSUB arg1 size arg2 + .globl _bcdn_sub +_bcdn_sub: + call load5_edca_hl + SYSTEM BCDSUB + ret + +; BLANK w h data video-addr + .globl _blank_area +_blank_area: + call load5_edca_hl + SYSTEM BLANK + ret diff --git a/presets/astrocade/astrocade.inc b/presets/astrocade/astrocade.inc new file mode 100644 index 00000000..163613c5 --- /dev/null +++ b/presets/astrocade/astrocade.inc @@ -0,0 +1,383 @@ + +; ****** HVGLIB.H (formally called ballyequ.h) (C)1977,78 +; *** Bally Astrocade Equates and Macros Header File *** +; From the nutting_manual and reformatted using Mixed Case +; Version 3.01 - thru December 29, 2010 +; by Richard C Degler, from scratch +; +; > Retyped and proofread by Adam Trionfo and Lance F. Squire +; > Version 1.0 (as ballyequ.h) - January 17, 2002 +; > Version 2.52 (Version 1.0 of HVGLIB.H) - March 28, 2003 +; > Version 2.6 - March 2, 2004 - as seen on BallyAlley.com +; > Version 3.0 - 2009 +; > Version 3.01 - Changed "FonT BASE character" comment +; +; *************************** +; * Home Video Game =ates * +; *************************** +; +; ASSEMBLY CONTROL +; +XPNDON = 1 ; ** SET TO 1 WHEN HARDWARE EXP +NWHDWR = 1 ; ** SET TO 1 WHEN NEW HARDWARE +; +; General goodies (HEX and Decimal values): +NORMEM = 0x4000 ; 8192 ; NORmal MEMory start +FIRSTC = 0x2000 ; 4096 ; FIRST address in Cartridge +SCREEN = 0x0000 ; 0 ; magic SCREEN start +BYTEPL = 0x28 ; 40 ; BYTEs Per Line +BITSPL = 0xA0 ; 160 ; BITS Per Line +; +; Stuff in SYSTEM DOPE VECTOR (valid for ALL system ROMs): +STIMER = 0x0200 ; Seconds and game TIMER, music +CTIMER = 0x0203 ; Custom TIMERs +FNTSYS = 0x0206 ; FoNT descriptor for SYStem font +FNTSML = 0x020D ; FoNT descriptor for SMaLl font +ALKEYS = 0x0214 ; ALl KEYS keypad mask +MENUST = 0x0218 ; head of onboard MENU STart +MXSCR = 0x021E ; address of 'MaX SCoRe' text string +NOPLAY = 0x0228 ; address of 'Number Of PLAYers' string +NOGAME = 0x0235 ; address of 'Number Of GAMEs' string +; +; BITS in PROCESSOR FLAG byte: +PSWCY = 0 ; Processor Status Word, CarrY bit +PSWPV = 2 ; Processor Status Word, Parity or oVerflow bit +PSWZRO = 6 ; Processor Status Word, ZeRO bit +PSWSGN = 7 ; Processor Status Word, SiGN bit +; +; BITS in GAME STATUS Byte: +GSBTIM = 0 ; Game Status Byte, if TIMe is up set end bit +GSBSCR = 1 ; Game Status Byte, if SCoRe reached set end bit +GSBEND = 7 ; Game Status Byte, END flag bit +; +; Standard VECTOR DISPLACEMENTS and bits: +VBMR = 0x00 ; +0 ; Vector Block, Magic Register +VBSTAT = 0x01 ; +1 ; Vector Block, STATus byte +VBTIMB = 0x02 ; +2 ; Vector Block, TIMe Base +VBDXL = 0x03 ; +3 ; Vector Block, Delta for X Low +VBDXH = 0x04 ; +4 ; Vector Block, Delta for X Hi +VBXL = 0x05 ; +5 ; Vector Block, X coord Low +VBXH = 0x06 ; +6 ; Vector Block, X coord Hi +VBXCHK = 0x07 ; +7 ; Vector Block, X CHecK flags +VBDYL = 0x08 ; +8 ; Vector Block, Delta for Y Low +VBDYH = 0x09 ; +9 ; Vector Block, Delta for Y Hi +VBYL = 0x0A ; +10 ; Vector Block, Y coord Low +VBYH = 0x0B ; +11 ; Vector Block, Y coord Hi +VBYCHK = 0x0C ; +12 ; Vector Block, Y CHecK flags +VBOAL = 0x0D ; +13 ; Vector Block, Old Address Low +VBOAH = 0x0E ; +14 ; Vector Block, Old Address Hi +; +; DISPLACEMENTS from start of COORDINATE AREA (X or Y): +VBDCL = 0x00 ; +0 ; Vector Block, Delta for Coord Low +VBDCH = 0x01 ; +1 ; Vector Block, Delta for Coord Hi +VBCL = 0x02 ; +2 ; Vector Block, Coord Low +VBCH = 0x03 ; +3 ; Vector Block, Coord Hi +VBCCHK = 0x04 ; +4 ; Vector Block, Coord CHecK flags +; +; BITS in STATUS byte: +VBBLNK = 6 ; Vector Block status, BLaNK bit +VBSACT = 7 ; Vector Block Status, ACTive bit +; +; BITS in (X or Y) VB CHECK FLAG bit mask: +VBCLMT = 0 ; Vector Block Check, LiMiT bit +VBCREV = 1 ; Vector Block Check, REVerse delta on limit attain +VBCLAT = 3 ; Vector Block Check, coordinate Limit ATtained +; +; FONT TABLE DISPLACEMENTS for CHARACTER DESCRIPTOR BLOCK: +FTBASE = 0x00 ; +0 ; FonT BASE character (normally 0xA0) +FTFSX = 0x01 ; +1 ; FonT Frame X Size width +FTFSY = 0x02 ; +2 ; FonT Frame Y Size height +FTBYTE = 0x03 ; +3 ; FonT X size for char in BYTEs +FTYSIZ = 0x04 ; +4 ; FonT Y SIZe height in rows +FTPTL = 0x05 ; +5 ; FonT Pattern Table address Low +FTPTH = 0x06 ; +6 ; FonT Pattern Table address Hi +; +; BITS for MAGIC REGISTER (write option) byte: +MRSHFT = 0x03 ; Magic Register, mask of SHiFT amount 0-3 +MRROT = 2 ; Magic Register, write with ROTata bit +MRXPND = 3 ; Magic Register, write with eXPaND bit +MROR = 4 ; Magic Register, write with OR bit +MRXOR = 5 ; Magic Register, write with eXclusive-OR bit +MRFLOP = 6 ; Magic Register, write with FLOP bit +; +; BITS of CONTROL HANDLE Input port: +CHUP = 0 ; Control Handle, UP bit +CHDOWN = 1 ; Control Handle, DOWN bit +CHLEFT = 2 ; Control Handle, joystick LEFT bit +CHRIGH = 3 ; Control Handle, joystick RIGHT bit +CHTRIG = 4 ; Control Handle, TRIGger bit +; +; CONTEXT BLOCK Register DISPLACEMENTS: +CBIYL = 0x00 ; +0 ; Context Block, IY register Low +CBIYH = 0x01 ; +1 ; Context Block, IY register Hi +CBIXL = 0x02 ; +2 ; Context Block, IX register Low +CBIXH = 0x03 ; +3 ; Context Block, IX register Hi +CBE = 0x04 ; +4 ; Context Block, E register +CBD = 0x05 ; +5 ; Context Block, D register +CBC = 0x06 ; +6 ; Context Block, C register +CBB = 0x07 ; +7 ; Context Block, B register +CBFLAG = 0x08 ; +8 ; Context Block, FLAGs register +CBA = 0x09 ; +9 ; Context Block, A register +CBL = 0x0A ; +10 ; Context Block, L register +CBH = 0x0B ; +11 ; Context Block, H register +; +; SENTRY RETURN Codes =ates: +SNUL = 0x00 ; Sentry return NULl, nothing happened +SCT0 = 0x01 ; Sentry, Counter-Timer 0 has counted down +SCT1 = 0x02 ; Sentry, Counter-Timer 1 has counted down +SCT2 = 0x03 ; Sentry, Counter-Timer 2 has counted down +SCT3 = 0x04 ; Sentry, Counter-Timer 3 has counted down +SCT4 = 0x05 ; Sentry, Counter-Timer 4 has counted down +SCT5 = 0x06 ; Sentry, Counter-Timer 5 has counted down +SCT6 = 0x07 ; Sentry, Counter-Timer 6 has counted down +SCT7 = 0x08 ; Sentry, Counter-Timer 7 has counted down +SF0 = 0x09 ; Sentry, Flag bit 0 has changed +SF1 = 0x0A ; Sentry, Flag bit 1 has changed +SF2 = 0x0B ; Sentry, Flag bit 2 has changed +SF3 = 0x0C ; Sentry, Flag bit 3 has changed +SF4 = 0x0D ; Sentry, Flag bit 4 has changed +SF5 = 0x0E ; Sentry, Flag bit 5 has changed +SF6 = 0x0F ; Sentry, Flag bit 6 has changed +SF7 = 0x10 ; Sentry, Flag bit 7 has changed +SSEC = 0x11 ; Sentry, SEConds timer has counted down +SKYU = 0x12 ; Sentry, KeY is now Up +SKYD = 0x13 ; Sentry, KeY is now Down +ST0 = 0x14 ; Sentry, Trigger 0 for player 1 has changed +SJ0 = 0x15 ; Sentry, Joystick 0 for player 1 has changed +ST1 = 0x16 ; Sentry, Trigger 1 for player 2 has changed +SJ1 = 0x17 ; Sentry, Joystick 1 for player 2 has changed +ST2 = 0x18 ; Sentry, Trigger 2 for player 3 has changed +SJ2 = 0x19 ; Sentry, Joystick 2 for player 3 has changed +ST3 = 0x1A ; Sentry, Trigger 3 for player 4 has changed +SJ3 = 0x1B ; Sentry, Joystick 3 for player 4 has changed +SP0 = 0x1C ; Sentry, POTentiometer 0 has changed +SP1 = 0x1D ; Sentry, POTentiometer 1 has changed +SP2 = 0x1E ; Sentry, POTentiometer 2 has changed +SP3 = 0x1F ; Sentry, POTentiometer 3 has changed +; +; +; ******************************** +; * Home Video Game PORT =ates * +; ******************************** +; +; OUTPUT Ports for VIRTUAL COLOR: +COL0R = 0x00 ; &(0)= ; write COLor 0 Right +COL1R = 0x01 ; &(1)= ; write COLor 1 Right +COL2R = 0x02 ; &(2)= ; write COLor 2 Right +COL3R = 0x03 ; &(3)= ; write COLor 3 Right +COL0L = 0x04 ; &(4)= ; write COLor 0 Left +COL1L = 0x05 ; &(5)= ; write COLor 1 Left +COL2L = 0x06 ; &(6)= ; write COLor 2 Left +COL3L = 0x07 ; &(7)= ; write COLor 3 Left +HORCB = 0x09 ; &(9)= ; write HORizontal Color Boundary +VERBL = 0x0A ;&(10)= ; write VERtical Blanking Line +COLBX = 0x0B ;&(11)= ; write COLor BloCK multi-port +; +; OUTPUT Ports for MUSIC and SOUNDS: +TONMO = 0x10 ;&(16)= ; write TONe Master Oscillator +TONEA = 0x11 ;&(17)= ; write TONe A oscillator +TONEB = 0x12 ;&(18)= ; write TONe B oscillator +TONEC = 0x13 ;&(19)= ; write TONe C oscillator +VIBRA = 0x14 ;&(20)= ; write VIBRAto frequency & range +VOLC = 0x15 ;&(21)= ; write VOLume of tone C +VOLAB = 0x16 ;&(22)= ; write VOLumes of tones A & B +VOLN = 0x17 ;&(23)= ; write VOLume of Noise +SNDBX = 0x18 ;&(24)= ; write SouND BloCK multi-port +; +; INTERRUPT and CONTROL OUTPUT Ports: +CONCM = 0x08 ; &(8)= ; write 0 for CONsumer, 1 for CoMmercial mode +MAGIC = 0x0C ;&(12)= ; write MAGIC register +INFBK = 0x0D ;&(13)= ; write INterrupt FeedBacK +INMOD = 0x0E ;&(14)= ; write INterrupt MODe +INLIN = 0x0F ;&(15)= ; write INterrupt LINe +XPAND = 0x19 ;&(25)= ; eXPANDer pixel definition port +; +; INTERRUPT and INTERCEPT INPUT Ports: +INTST = 0x08 ; =&(8) ; read INTercept STatus +VERAF = 0x0E ;=&(14) ; read VERtical Address Feedback +HORAF = 0x0F ;=&(15) ; read HORizontal Address Feedback +; +; HAND CONTROL INPUT Ports: +SW0 = 0x10 ;=&(16) ; read SWitch bank 0 for player 1 hand control +SW1 = 0x11 ;=&(17) ; read SWitch bank 1 for player 2 hand control +SW2 = 0x12 ;=&(18) ; read SWitch bank 2 for player 3 hand control +SW3 = 0x13 ;=&(19) ; read SWitch bank 3 for player 4 hand control +POT0 = 0x1C ;=&(28) ; read POTentiometer 0 for player 1 knob +POT1 = 0x1D ;=&(29) ; read POTentiometer 1 for player 2 knob +POT2 = 0x1E ;=&(30) ; read POTentiometer 2 for player 3 knob +POT3 = 0x1F ;=&(31) ; read POTentiometer 3 for player 4 knob +; +; KEYBOARD INPUT Ports: +KEY0 = 0x14 ;=&(20) ; KEYboard column 0 (right side) +KEY1 = 0x15 ;=&(21) ; KEYboard column 1 (center right) +KEY2 = 0x16 ;=&(22) ; KEYboard column 2 (center left) +KEY3 = 0x17 ;=&(23) ; KEYboard column 3 (left side) +; +; +; *************************************** +; * Home Video Game SYSTEM CALL Indexes * +; *************************************** +; +; USER PROGRAM Interface: +INTPC = 0x00 ; # 0 ; INTerPret with Context create +XINTC = 0x02 ; # 2 ; eXit INTerpreter with Context +RCALL = 0x04 ; # 4 ; Real CALL asm language subroutine +MCALL = 0x06 ; # 6 ; Macro CALL interpreter subroutine +MRET = 0x08 ; # 8 ; Macro RETurn from interpreter subroutine +MJUMP = 0x0A ; # 10 ; Macro JUMP to interpreter subroutine +SUCK = 0x0C ; # 12 ; SUCK inline args into context block +; +; SCHEDULER Routines: +ACTINT = 0x0E ; # 14 ; ACTivate sub timer INTerrupts +DECCTS = 0x10 ; # 16 ; DECrement CTS under mask +; +; MUSIC and SOUNDS: +BMUSIC = 0x12 ; # 18 ; Begin playing MUSIC +EMUSIC = 0x14 ; # 20 ; End playing MUSIC +; +; SCREEN HANDLER Routines: +SETOUT = 0x16 ; # 22 ; SET some OUTput ports +COLSET = 0x18 ; # 24 ; COLors SET +FILL = 0x1A ; # 26 ; FILL memory with data +RECTAN = 0x1C ; # 28 ; paint a RECTANgle +VWRITR = 0x1E ; # 30 ; Vector WRITe Relative +WRITR = 0x20 ; # 32 ; WRITe Relative +WRITP = 0x22 ; # 34 ; WRITe with Pattern size lookup +WRIT = 0x24 ; # 36 ; WRITe with sizes provided +WRITA = 0x26 ; # 38 ; WRITe Absolute +VBLANK = 0x28 ; # 40 ; Vector BLANK area +BLANK = 0x2A ; # 42 ; BLANK area +SAVE = 0x2C ; # 44 ; SAVE area +RESTOR = 0x2E ; # 46 ; RESTORe area +SCROLL = 0x30 ; # 48 ; SCROLL area of screen +; +CHRDIS = 0x32 ; # 50 ; CHaRacter DISplay +STRDIS = 0x34 ; # 52 ; STRing DISplay +DISNUM = 0x36 ; # 54 ; DISplay NUMber +; +RELABS = 0x38 ; # 56 ; RELative to ABSolute conversion +RELAB1 = 0x3A ; # 58 ; RELative to non-magic ABSolute +VECTC = 0x3C ; # 60 ; VECTor move single Coordinate +VECT = 0x3E ; # 62 ; VECTor move coordinate pair +; +; HUMAN INTERFACE Routines: +KCTASC = 0x40 ; # 64 ; Key Code in B To ASCii +SENTRY = 0x42 ; # 66 ; SENse TRansition Y +DOIT = 0x44 ; # 68 ; DOIT table, branch to translation handler +DOITB = 0x46 ; # 70 ; DOIT table, use B instead of A +PIZBRK = 0x48 ; # 72 ; take a PIZza BReaK +MENU = 0x4A ; # 74 ; display a MENU +GETPAR = 0x4C ; # 76 ; GET game PARameter from user +GETNUM = 0x4E ; # 78 ; GET NUMber from user +PAWS = 0x50 ; # 80 ; PAUSE +DISTIM = 0x52 ; # 82 ; DISplay TIMe +INCSCR = 0x54 ; # 84 ; INCrement SCoRe +; +; MATH Routines: +INDEXN = 0x56 ; # 86 ; INDEX Nibble by C +STOREN = 0x58 ; # 88 ; STORE Nibble in A by C +INDEXW = 0x5A ; # 90 ; INDEX Word by A +INDEXB = 0x5C ; # 92 ; INDEX Byte by A +MOVE = 0x5E ; # 94 ; MOVE block transfer +SHIFTU = 0x60 ; # 96 ; SHIFT Up digit in A +BCDADD = 0x62 ; # 98 ; BCD ADDition +BCDSUB = 0x64 ;# 100 ; BCD SUBtraction +BCDMUL = 0x66 ;# 102 ; BCD MULtiplication +BCDDIV = 0x68 ;# 104 ; BCD DIVision +BCDCHS = 0x6A ;# 106 ; BCD CHange Sign +BCDNEG = 0x6C ;# 108 ; BCD NEGate to decimal +DADD = 0x6E ;# 110 ; Decimal ADDition +DSMG = 0x70 ;# 112 ; Decimal convert to Sign MaGnitude +DABS = 0x72 ;# 114 ; Decimal ABSolute value +NEGT = 0x74 ;# 116 ; decimal NEGaTe +RANGED = 0x76 ;# 118 ; RANGED random number +QUIT = 0x78 ;# 120 ; QUIT cassette execution +SETB = 0x7A ;# 122 ; SET Byte +SETW = 0x7C ;# 124 ; SET Word +MSKTD = 0x7E ;# 127 ; MaSK joystick in B To Deltas +; +; +; *************************** +; * SYSTEM RAM MEMORY Cells * +; *************************** +WASTE = 0x0FFF +WASTER = WASTE +; +SYSRAM = 0x4FCE ; Resides at the highest possible address +BEGRAM = SYSRAM ; typically used for initial Stack Pointer +; Used by MUSIC PROCESSOR: +MUZPC = 0x4FCE ; MUSic Program Counter +MUZSP = 0x4FD0 ; MUSic Stack Pointer +PVOLAB = 0x4FD2 ; Preset VOLume for tones A and B +PVOLMC = 0x4FD3 ; Preset VOLuMe for tone C and Noise Mode +VOICES = 0x4FD4 ; music VOICES mask +; COUNTER TIMERS (used by DECCTS,ACTINT,CTIMER): +CT0 = 0x4FD5 ; Counter Timer 0 +CT1 = 0x4FD6 ; Counter Timer 1 +CT2 = 0x4FD7 ; Counter Timer 2 +CT3 = 0x4FD8 ; Counter Timer 3 +CT4 = 0x4FD9 ; Counter Timer 4 +CT5 = 0x4FDA ; Counter Timer 5 +CT6 = 0x4FDB ; Counter Timer 6 +CT7 = 0x4FDC ; Counter Timer 7 +;Used by SENTRY to track controls: +CNT = 0x4FDD ; Counter update & Number Tracking +SEMI4S = 0x4FDE ; SEMAPHORE flag bitS +OPOT0 = 0x4FDF ; Old POT 0 tracking byte +OPOT1 = 0x4FE0 ; Old POT 1 tracking byte +OPOT2 = 0x4FE1 ; Old POT 2 tracking byte +OPOT3 = 0x4FE2 ; Old POT 3 tracking byte +KEYSEX = 0x4FE3 ; KEYS-EX tracking byte +OSW0 = 0x4FE4 ; Old SWitch 0 tracking byte +OSW1 = 0x4FE5 ; Old SWitch 1 tracking byte +OSW2 = 0x4FE6 ; Old SWitch 2 tracking byte +OSW3 = 0x4FE7 ; Old SWitch 3 tracking byte +COLLST = 0x4FE8 ; COLset LaST address for P.B. A +; Used by STIMER: +DURAT = 0x4FEA ; note DURATion +TMR60 = 0x4FEB ; TiMeR for SIXTYths of sec +TIMOUT = 0x4FEC ; TIMer for blackOUT +GTSECS = 0x4FED ; Game Time SECondS +GTMINS = 0x4FEE ; Game Time MINuteS +; Used by MENU: +RANSHT = 0x4FEF ; RANdom number SHifT register +NUMPLY = 0x4FF3 ; NUMber of PLaYers +ENDSCR = 0x4FF4 ; END SCoRe to 'play to' +MRLOCK = 0x4FF7 ; Magic Register LOCK out flag +GAMSTB = 0x4FF8 ; GAMe STatus Byte +PRIOR = 0x4FF9 ; PRIOR music protect flag +SENFLG = 0x4FFA ; SENtry control seizure FLaG +; User UPI Routines, even numbers from 0x80 to 0xFE ( + 1 for SUCK): +UMARGT = 0x4FFB ; User Mask ARGument Table + (routine / 2) +USERTB = 0x4FFD ; USER Table Base + routine = JumP address +; +URINAL = 0x4FFF ; WASTER flushes here! +; +; + +; +; MACROs to generate SYSTEM CALLs: + .macro SYSTEM NUMBA + rst 0x38 + .db NUMBA +; .if NUMBA = INTPC +;INTPCC = 1 +; .endif + .endm +; MACRO to generate SYSTEM CALL with SUCK option ON: + .macro SYSSUK UMBA + rst 0x38 + .db UMBA + 1 +; .if UMBA = INTPC +;INTPCC = 1 +; .endif + .endm +; MACROs to generate MACRO INTERPRETER CALLs: +; INTERPRET without INLINE SUCK: + .macro DONT CID + .db CID + .endm +; INTERPRET with INLINE SUCK option ON: + .macro DO CID + .db CID + 1 + .endm diff --git a/presets/astrocade/hdr_autostart.s b/presets/astrocade/hdr_autostart.s index a988634e..8de35957 100644 --- a/presets/astrocade/hdr_autostart.s +++ b/presets/astrocade/hdr_autostart.s @@ -6,4 +6,9 @@ jp start ; jump to main() start: ld sp,#0x4fce + ld BC, #l__INITIALIZER + ld A, B + ld DE, #s__INITIALIZED + ld HL, #s__INITIALIZER + ldir jp _main diff --git a/presets/astrocade/hdr_standard.s b/presets/astrocade/hdr_standard.s new file mode 100644 index 00000000..07e625f2 --- /dev/null +++ b/presets/astrocade/hdr_standard.s @@ -0,0 +1,16 @@ + + .include "astrocade.inc" + +; Minimal header file for use with Astrocade C programs + + .area _CODE + + .db 0x55 ; sentinel + .dw MENUST + .dw PrgName + .dw PrgStart +PrgName: + .ascii "8BITWORKSHOP" + .db 0 +PrgStart: + jp _main diff --git a/presets/astrocade/hello.c b/presets/astrocade/hello.c index ae9833e9..8655e450 100644 --- a/presets/astrocade/hello.c +++ b/presets/astrocade/hello.c @@ -1,4 +1,5 @@ +//#resource "astrocade.inc" #include "aclib.h" //#link "aclib.c" //#link "hdr_autostart.s" @@ -26,7 +27,12 @@ const byte BALL[] = { 0b01111000, }; -void main() { + +// BCD number +byte bcdnum[3] = {0x56,0x34,0x12}; +byte bcdinc[3] = {0x01,0x00,0x00}; + +void main(void) { // clear screen clrscr(); // setup palette @@ -34,7 +40,7 @@ void main() { // set screen height // set horizontal color split (position / 4) // set interrupt status - SYS_SETOUT(98*2, 23, 0); + SYS_SETOUT(89*2, 23, 0); // display standard characters display_string(2, 2, OPT_ON(1), "HELLO, WORLD!!"); // 2x2 must have X coordinate multiple of 2 @@ -45,16 +51,21 @@ void main() { display_string(4, 38, OPT_4x4|OPT_ON(3)|OPT_OR, "4X4"); // and XOR mode to invert existing pixels // (careful, there's no clipping) - display_string(101, 24, OPT_8x8|OPT_ON(3)|OPT_XOR, "?"); + display_string(109, 24, OPT_8x8|OPT_ON(3)|OPT_XOR, "?"); // small font must be aligned to multiple of 4 display_string(4, 80, OPT_ON(1), "\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9"); // paint a rectangle with a pattern mask (0xa5) - paint_rectangle(4, 72, 90, 4, 0xa5); + paint_rectangle(4, 72, 100, 4, 0xa5); // write from pattern block write_relative(50, 80, M_XPAND, BALL); write_relative(60, 80, M_XPAND, BALL); - write_relative(70, 80, M_XPAND, BALL); + // write_pattern() doesn't use the x/y offset + write_pattern(70, 80, M_XPAND, BALL+2); // infinite loop + activate_interrupts(); while (1) { + display_bcd_number(80, 80, OPT_ON(2), bcdnum, 6|DISBCD_SML|DISBCD_NOZERO); + bcdn_add(bcdnum, 3, bcdinc); + sleep(60); } } diff --git a/presets/astrocade/skeleton.sdcc b/presets/astrocade/skeleton.sdcc index 5aa6244e..e88849c5 100644 --- a/presets/astrocade/skeleton.sdcc +++ b/presets/astrocade/skeleton.sdcc @@ -1,29 +1,33 @@ #include "aclib.h" //#link "aclib.c" -//#link "acheader.s" +//#link "hdr_autostart.s" +#include "acbios.h" +//#link "acbios.s" #include #include -void setup_registers() { - // setup colors - hw_col0r = 0x00; - hw_col1r = 0x2f; - hw_col2r = 0xef; - hw_col3r = 0xaf; - // horizontal palette split - hw_horcb = 12; - // height of screen - hw_verbl = VHEIGHT*2; -} +/*{pal:"astrocade",layout:"astrocade"}*/ +const byte palette[8] = { + 0x77, 0xD4, 0x35, 0x01, + 0x07, 0xD4, 0x35, 0x01, +}; -void main() { - setup_registers(); +void main(void) { + // clear screen clrscr(); - hw_xpand = XPAND_COLORS(0, 2); - draw_string("Hello, World!", 2, 0); + // setup palette + set_palette(palette); + // set screen height + // set horizontal color split (position / 4) + // set interrupt status + SYS_SETOUT(89*2, 23, 0); + // display standard characters + display_string(2, 2, OPT_ON(1), "HELLO, WORLD!!"); // infinite loop + activate_interrupts(); while (1) { + sleep(1); } } diff --git a/presets/astrocade/vsync.c b/presets/astrocade/vsync.c index ef9f565b..090a05d3 100644 --- a/presets/astrocade/vsync.c +++ b/presets/astrocade/vsync.c @@ -1,6 +1,7 @@ #include +//#resource "astrocade.inc" #include "aclib.h" //#link "aclib.c" //#link "hdr_autostart.s" @@ -34,10 +35,7 @@ void main() { activate_interrupts(); while (1) { write_relative(x, y, M_MOVE, player_bitmap); - wait_for_vsync(); + sleep(1); x++; -// erase_sprite(player_bitmap, x, y); -// x++; -// y++; } } diff --git a/src/platform/astrocade.ts b/src/platform/astrocade.ts index d202a33d..d6e4a083 100644 --- a/src/platform/astrocade.ts +++ b/src/platform/astrocade.ts @@ -11,7 +11,7 @@ const ASTROCADE_PRESETS = [ {id:'01-helloworlds.asm', name:'Hello World'}, {id:'02-telephone.asm', name:'Telephone'}, {id:'03-horcbpal.asm', name:'Paddle Demo'}, - {id:'hello.c', name:'Hello World'}, + {id:'hello.c', name:'Hello Graphics'}, {id:'lines.c', name:'Lines'}, {id:'sprites.c', name:'Sprites'}, {id:'vsync.c', name:'Sprites w/ VSYNC'}, @@ -266,7 +266,8 @@ const _BallyAstrocadePlatform = function(mainElement, arcade) { break; case 0xc: // magic register magicop = val; - shift2 = 0; + //shift2 = 0; // TODO? + xplower = false; break; case 0xd: // INFBK (interrupt feedback) infbk = val; @@ -292,7 +293,6 @@ const _BallyAstrocadePlatform = function(mainElement, arcade) { break; case 0x19: // XPAND xpand = val; - xplower = false; break; default: console.log('IO write', hex(addr,4), hex(val,2));