Home

ColecoVision Coding Guide

image

Contents

1. belong to this object s pattern generator And replace with name from OLD SCREEN which P corresponds to that pattern position PM3 ld hl WORK BUFFER HL BUFFER BASE ld de YP_BK 1 add hl de Point to lst of background names exx ld de WORK BUFFER BUFFER BASE ld hl YP 0541 add hl de ex de hl Points to 1st of OLD SCREEN names exx i id iy WORK BUFFER ld c iy F GEN FIRST GEN id b 009H DEPTS id a hl Get a name sub c Substract FIRST GEN NAME AyjLT 18 Then name falls in range of names for object cp 012H JE nc END3 If _A GE 9 Then sub 9 to find correct cp 009H JE END4 sub 009H Position in OLD SCREEN END4 ENDIF i exx ld 1 Form a pointer into OLD SCREEN names ld h 000H add hl de ld a hl Get OLD SCREEN NAME exx id 1 Replace background name with OLD SCREEN name END3 hl Point to next name in background djnz DLP1 Now new version of background names will not contain any names of this object Replace previous version of OLD SCREEN with this new background PM4 pop de DE OLD SCREEN address id hl WORK BUFFER HL BUFFER base ld bc XP BK add hl bc HL points to background position and names ld bc 0000BH Number of bytes to move H if D LT 70H Then move data to VRAM 1 070H jr nc ELSE5
2. REST no sound 7 6 5 4 3 2 1 0 Channel 1 Length SIMPLE NOTE 7 6 5 4 3 2 1 0 Channel 0 0 0 0 0 0 Frequency 8 lower bits Volume in 4 bits 0 0 Frequency 2 hi bits Length FREQUENCY SWEPT NOTE 7 6 5 4 3 2 1 0 Channel 0 0 0 0 0 1 Frequency 8 lower bits Volume in 4 bits 0 0 Frequency 2 hi bits Number of steps in sweep Step length 1 step length Step size VOLUME SWEPT NOTE 7 6 5 4 3 2 1 0 Channel 0 0 0 0 1 0 Frequency 8 lower bits Volume in 4 bits 0 0 Frequency 2 hi bits Length of note Step size Number of steps Step length 1 step length VOLUME AND FREQUENCY SWEPT NOTE 7 6 5 4 3 2 1 0 Channel 0 0 0 0 1 1 Frequency 8 lower bits Volume in 4 bits 0 0 Frequency 2 hi bits Number of steps in sweep Frequency step length 1 frequency step length Frequency step size Volume step Number of volume step Volume step length 1 volume step length 190 NOISE 4 6 5 4 3 2 1 0 0 0 0 0 0 0 1 0 Unused byte Volume in 4 bits 0 FB Length of note For the special meaning of FB and NFO read section SOUND GENERATOR page 188 NOISE VOLUME SWEEP 7 6 5 4 3 2 1 0 0 0 0 0 0 0 1 0 Initial volum
3. jp EST SIGNAL TIME MGR jp TIME MGR TURN OFF SOUND jp ALL OFF WRITE REGISTER jp REG WRITE READ REGISTER jp REG READ WRITE VRAM jp VRAM WRITE READ VRAM jp VRAM READ INIT WRITER jp INIT QUEUE WRITER jp WRITER POLLER jp POLLER SOUND INIT jp INIT SOUND PLAY IT jp JUKE BOX SOUND MAN jp SND MANAGER ACTIVATE jp ACTIVATE PUTOBJ jp PUTOBJ _ RAND GEN jp RAND GEN u 24 Ij 1 1 6 1 9 1 lFAF 1FB2 1FB5 1FB8 1FBB 1 1FC4 lFC7 1 1FCD 1FD6 1 09 1FDC rj N u u u w 1FF1 1 4 lFF7 lFFA lFFD 178 See See See See See See See See See See See See See See See See See See See See See See See See See See See See See See See page page page page page page page page page page page page page page page page page page page page page page page page page page page page page page page 1 37 165 166 167 100 80 82 158 160 162 162 163 133 133 135 137 131 81 165 167 166 167 100 100 142 80 82 83 93 102 68 APPENDIX 179 OS 7 JUMP TAB
4. COMMENT address of byte 0 of a song data area is passed in IX song of the song using that area is returned in OFFH if inactive If a special effect was using that area 62 is returned in A and HL is returned with the address of the special sound effect routine i AREA_SONG IS ld a ix 000H CH SONGNO or 62 or A FF cp OFFH ret 2 leave if A FF area inactive and 03FH mask CH cp ret nz leave with SONGNO not a special effect push ix point HL to byte 1 pop hl inc hl 1 1 save LSB effect addr in E inc hl HL to byte 2 ld d bib save MSB effect addr in D ex de hl addr special effect ret 79 INIT SOUND IDENT INITSOU includes INIT SOUND ALL OFF B B 22 INIT SOUND 2 ke ke koe kc ke ke ke ko e COMMENT j Users Manual for description includes ENTRY POINT ALL OFF addr LST OF SND ADDRS passed in HL 4 of song data areas to init passed in B i Globals INCLUDE RNATN SOUND PORT RlATN R2ATN R3ATN 1 R2FRQ 1 R3FRQ 1 RNCTL GLB Defines INIT SOUND ALL OFF DUMAREA OSSR_EQU 0S 0 equates EQU OFFH 090H OBOH ODOH OFOH 080H OAOH OCOH OEOH EQU
5. SPRITE GRAPHICS RECORD OBJECT TYPE BYTE FIRST GEN a Name of the 1st sprite generators Pointer to ROM ed generators Number of ROM ed generators E table of animation frames E PTRN POINTER PATTE NUMGEN BYTE 7 FRAME TABLE PTR ARRAY 0 nn of FRAM END SPRITE ROM GRAPHICS RN GENERATOR SPRITE STATUS RECORD M FRAME BYTE Current animation frame X LOCATION INTEGER Y LOCATION INTEGER NEXT GEN BYTE Index of fr Space in generator table END SPRITE STATUS FRAME RECORD COLOR SHAPE BYTI END FRAME Sprite s color for this frame This frame s offset from name from FIRST GEN NAME Sn SPRITE RECORD Y BYTE X BYTE NAME BYTE COLOR AND TAG BYTE END SPRITE kck kk ck kk DICTIONARY External EXT WORK BUFFER WORK BUFFER is a pointer in cartridge ROM located at 80065 to the buffer area to be used by the graphics routines Defines SPRITE PTR EQU IY SPRITE PTR is
6. CO CO CO CO CO CO CO CO CO C2 CO CO CO Oo C Ooo OO 0 OO OQ CO CO CO CO CO CO OO CO CO CO CO CO CO CO CO gt ooo O gt lt CO C5 63 C93 C gt gt 6 ONO OOGO X aX 020 000 gt gt gt O o oo 2 5 c CTI C C T 3 C CI CX C3 gt O CJ lt gt CY CO OC OO C C C CJ CO 0 c 00000 co oo C93 O 3 03 03 3 113 lt gt 5 65 lt C cC gt O 0000000000000 8 t gt 8 oe gt s 1 OY O1 C V mark space db OFOH 088H 088H OFOH OAOH 090H 088H OOOH db 070H 088H 080H 070H 008H 0
7. 24 OBJECT ROUTINES ee ROS E 25 ACTIVATE M 26 WRITE n HENRI do Ie or DO Cte 27 WIRETER 2 Gi RP OE UR PER ERR QUU OR tte aset 28 te CMe 29 uut Lo 30 DO RO VOB 31 PUTS ENE soci ite tek 32 33 ob detiene dre dede abe Ud er des 34 BR GRIND 5 E tue 35 CALC JORFSET UNDA 36 H ies 37 PUTISPRITE merrer non 38 PUT MOBILE o 39 PUT COMPLEX C 40 TIMER ROUTINES etii e p e b pe e Pr ie ee 41 TIMEZMOGR acne tee ner ee TERR REA ER Eee P 42 INTE TIMER eher ER Ee acta RE TERT R 43 iii REQUEST SIGN AM se tede edat UR m a tan D Get DDR LE RO E 45 TEST SIGNA D s An ui e nM Sec Wc d D RA DUMP EINE 46 CONTROLLE
8. Pixels to right of pattern boundary DE Y LOCATION Calculate Y PAT POS And Save names that constitute the background on which object will be superimposed hl de hl d e bc GE d e a ix iy i de hl bc hl bc a 07 WORK BUFFE 1 de iy YP_BK iy XP_BK 00303H T BKGRND 1 005 1 004 1 006 WORK EN a WORK BUFFE XP OS 0000 OH R old screen into buffer and get COLOR and Point to space for background names D Y POS E X POS B Y EXTENT X EXTENT Get background names 1st GEN NAME DE EN address OLD SCRE Get first GEN NAME IX Address of graphics Save in buffer Save OLD SCREEN address HL Addr of start of buffer Space to move OLD SCREEN to Get 9 names from VRAM Then OLD SCREEN is in VRAM 117 jr nc ELSE2 call READ VRAM END2 ELSE OLD SCREEN in CPU RAM ELSE2 ex de hl ldir END2 At this point IX GRAPHICS SP OLD SCREEN BACKGROUND pattern position and names starting at YP BK OLD SCREEN pattern position and names starting at YP OS Find all names in background which
9. Much Ton ata asad 175 176 TABLE Nl 177 PEAY SONGS 177 NINTENDO 177 PUTOBIP e c LE LEN ML S RP 177 REFLECT et RR LIP E EAE 177 KEELECTHORIZONTAE 177 E tL ME C m a 177 E 177 CONBBOLPEROSCANSO S MR LL D AM E 177 DECODER o t cR c E mi M LL A A AUR 177 177 D D 177 RM NE 177 MODE Du LI EU D E MM ML ML 177 UPDATE SPINNERS s uites scott ades E 177 INIT TABLE GO 177 GEI M ME E d ea M 177 PUT VRAMP uL M SN D NR AME 177 SPR CORIO LEE D AV ott ret 177 es ien 177 R M E MR ME AK M MEE 177 HREESSIGNADPS a Miren eair 177 TRB OUEST 5 GNA E ER UE A eui e clt 177 MESEIS
10. ke ke kc ck ke ok e COMMENT j Without affecting the MSN decrement the LSN of the byte pointed to by HL HL remains the same with Z flag set if dec LSN results in 0 reset otherwise RET with C flag set if dec LSN results in 1 reset otherwis i DECLSN ld a 000H rrd 0 LSN HL sub 001H Z flag set if dec to 0 C flag if dec to 1 push af save 2 and C flag rld HL old MSN new LSN pop af restore Z and C flags A 0 new LSN ANKE DECMSN ko koe ke ke ko ke ko koe e ke ke ke ke KK COMMENT j Without affecting the LSN decrement the MSN of the byte pointed to by HL HL remains the same RET with Z flag set if dec MSN results in 0 reset otherwis RET with C flag set if dec MSN results in 1 reset otherwise i DECMSN 1 a 000H rid 0 MSN HL sub 001H Z flag set if dec to 0 C flag if dec to 1 push af save 2 C flag rrd HL new MSN old LSN pop af restore 2 and C flags 0 new MSN ret M gt MSNTOLSN ko koe e koc ke kc ke kc ke ke ke ke e COMMENT j Copy MSN of the byte pointed to by HL to the LSN of that byte HL remains the same i MSNTOLSN ld a hl MSN LSN to be changed and OFOH MSN O ld b a save in B rrca swap nibbles rrca rrca rrca
11. P Re 110 PUIOSPBIDER e t A 111 PUTI SPRITES E Ce e 112 PUPMOBIEES rue T e ROME A 116 PUR MOBILE ee ata M De pA Ma Bd ipe aN 116 PUPCOMPLEX c s ueste LEM Lee 128 PUICOMPDE X cx tot ck d c Me ER 128 TIME MANAGERS ri D e lu ds a 131 TIME rein 131 Ns Be ase expt ere e O sot 133 INE TIMER e 133 EREECSIGNAT QS aca tanh dont ed bere 133 PB SIGNAL ort ceto mU Mr A 133 COUN Pea ede eu 134 REQUEST SIGNALS 135 BEOUPSTOSIQNAT 135 SIGNADO 137 LE LN REAL 137 CONTROLLER SOFTWARE Samana DN M E 139 CONTROLER TINIE essc c io are ak D E E 140 CONT te IM NA M E E M uL m 140 CONTISCAN C ram
12. ttt ttt ttt ttt tistttid 187 SOUND GENBRATOR tice EU EH I RID E 188 TONEGENERABORS tte idt diens 188 NOISE GENERATOR scutis sev ibiteDa let A CMM E AR PM UT 188 CONTROL REGISTER Sy eae 188 SOUND CONTROL DATA 189 SOUND CONTROL NUMBERS ttt ttt ttt ttti 189 SOUNDIDATA 50 8 T N e Seated 190 RESP MM mre 190 190 FREQUENCY SWEPT NOM 190 190 VOLUME AND FREQUENCY SWEPT 190 hd E e 191 etate edes LM eed 191 SPECIAL EFFEC Te ue wes cce ettet REI DN DUM DE D Ne ee 191 FND OR REPEAT S pi Aesth all cea EM 191 vil SONG DATA AREAS IN RAM SONG TABLE IN ae eal s P ERR T e OUTPUT TABLE IN RAM NOTES AND FREQUENCIES NOTE FREQUENCY CONVERSION TABLE SCALES beth tt t CORR SIS RV e Pe reu REI DUI oan itu ree i VDP VIDEO DISPLAY PROCESSOR 6 e eaa EAR Me Le er te re ie OREL ce tie
13. ck k KKK PROCEDURE REG WRITEO REGISTER BYTE VALUE BYTE REGISTER is passed to B register VALUE is passed to C register DESTROYS REG WRITE P dw 00002H dw 00001H dw 00001H REG WRITEQ ld bc REG WRITE P id de PARAM AREA call PARAM ld hl PARAM AREA id c h ld b l REG WRITE 1 out CTRL PORT a Ld a b add a 080H out CTRL PORT a id a b cp 000H jr nz NOT REG 0 ld a c ld VDP MODE WORD a 165 NOT REG 0 ld jr ld ld NOT REG 1 ret PROCEDURE VAR DATA pointer to data buffer is passed in VRAM WRITEO a b 001H nz NOT REG 1 a c VDP MODE 1 DEST is passed in DE COUNT is passed in BC DESTROYS ALL VRAM WRITE P dw 00003H dw OFFFEH dw 00002H dw 00002H WRITE VRAMQ ld ld call ld ld ld VRAM WRITE push push pop ld add ld out ld out push pop pop ld ld OUTPUT LOOP outi nop nop jp dec jp jr END OUTPUT ret PROCEDURE VRAM R VAR DATA poin bc VRAM WRITE P de PARAM AREA PARAM hl PARAM AREA de PARAM AREA 2 bc PARAM AREA 4 hl de hl 04000H hl de a l CTRL PORT a a h CTRL PORT a bc de hl c DATA PORT b e nz OUTPUT LOOP d m END OUTPUT nz OUTPUT LOOP SRCE
14. 118 DLP2 PM52 PM51 PM6 call jr Else Ldir ENDIF push call push srl srl srl id id sub ld id add ld WRITE VRAM END5 T Move ix de WORK BUFFER hl YP 1 hl de de hl bc BK PTN 8 hl bc b 009H a de de de 00008H hl de hl e a 000H bc a 009H b b 000H 003H PM51 b PM52 a b iy WORK_BUFFER a BK 7 Ly FLAGS iy 00001H PSW IS ZERO nz ELSE6 a 003H GET VRAM bc hl WORK BUFFER bc de BK CLR hl de e c e e e d 000H a 009H b b 000H hl bc iy 00001H to CPU RAM Save graphics pointer DE BUFFER base Displacement to beginning of BKGND names DE point to first background name HL points to background PAT GET storage area will be incremented before 15 use Get name point to next name Save name pointer increment BUFFER pointer Save BUFFER pointer Index into pattern table Save pattern name in C Save counter ADD b 9 3 to YP BK to find out which third of tables GENs are in M Test graphics mode Number of elements read Then MODE I Code for pattern generator table Get count and name Displacement to COLOR GEN AREA Point to it Pattern name Divide name by 8 Calc position in buffer to move GEN to 119 PM7 R screen pop
15. M2 EXT 1 4 16K BL GINT MI M3 SI MAG 2 13 12 PNII 10 3 0 9 CT8 CT7 CT6 4 PGI2 PGII 5 SA13 5412 SA11 SA10 SA9 SA8 SA7 6 SG13 SG12 SG11 7 TC3 TC2 TCI TCO BD3 BD2 BDI 1 M2 M3 Select screen mode EXT Enables external video input 4 16K Selects 16K Video RAM if set BL Blank screen if reset SI 16x16 sprites if set 8x8 if not MAG Sprites enlarged if set double sized sprite pixels are 2x2 GINT Generate interrupts if set PN Address for pattern name table screen R2 400h CT Address for colour table special meaning in M2 R3 40h PG Address for pattern generator table special meaning in M2 R4 800h SA Address for sprite attribute y x pattern colour table R5 80h SG Address for sprite generator table R6 800h TC Text colour foreground BD Backdrop background border STATUS REGISTER INT 55 54 53 52 51 50 5 Fifth sprite first sprite not displayed Valid if 5S is set C Sprite collision detected 5S Fifth sprite not displayed detected INT Set at each screen update refresh 194 VDP REGISTER ACCESS The status register can t be write After reading the status register INT bit 7 and bit 5 are reset ASM in a Obfh get register value COLECO BIOS IFDC Output A vdp status register value The control registers can t be read Two bytes must be writen Bit 7 Bit 6 Bit 5
16. hl ld d 1 push de pop ix ret EAVE EFFECT ke ke ke ke KK COMMENT j LEAVE EFFECT restores the SONGNO of song to which t byte 0 in the effect s data area and the next note in the song The addres effect when 156 called is passed in D in the song also saved by the effect pointing to byte 0 of the data area to i restored Bits 7 and 6 of the saved SONGNO are ignored m called by a special sound effect routine when it s finished h ffect note belongs to B5 BO of loads bytes 1 and 2 with the address of S of the 1 byte SONGNO saved by the E The 2 byte address of the next note is passed in HL IX is assumed to be which the song number is to be and therefore may be 78 used by the effect to store flag information during the course of the not i LEAVE EFFECT id ix 001H 1 LSB NEXT NOTE PTR LSB addr next note in song ld ix 002H h MSB NEXT NOTE PTR MSB addr next note in song ld a de x x SONGNO i e the saved original SONGNO and 0 0 SONGNO Ld b a Saved in B ld a ix 000H CH 62 all effect notes have SONGNO 62 and OCOH CH 000000 or b PA CH SONGNO ld 1 000 restore song number ret ke ke ke AREA SONG IS
17. 178 tte it as eae 178 WBITECURAMPBS M Mi eas Ae ep RUM dd 178 READ VRAMD chad SL ed M M E A Id 178 vi INIT WRITER toto suse aD MA pU 178 SOUND INTIP E des 178 UG ia dc a EA TM D CRIME 178 TIE AB OB dL EN a Ree 178 GEVRA ar eM LE n 178 PUT see eu E e LL LI tie 178 INIT SPR ORDER racc mu teresa t a M 178 WR SERS NM THES vastas n M RO 178 M PUR dM Me ELE 178 REE 178 MI KD E Dtm ate eons d A ARE 178 TEST SIGNA eat Mae ech Rn LEM t E taal 178 TIME MGR the ce mte M E MD tM CA m 178 TURN SOUND mas 178 WRITEAREGISTERS e met p t EE M MEA p e t uaa 178 READ So ecce 178 178 READ VRAM m Co Eie iMd PR
18. EXTI EXTI HL ENT HL ENT Y EXTI BC HL Number of bytes to write Free buffer addr 105 END IF 4 ret kkkxkxkxkxkxkxkxkkkxkxkkxkxkkkkxkkkkkkkxkxk PX TO PTRN POS ck ck Description Divides reg by 8 If signed result gt 127 Then E Max signed H Positiv number If result 128 Then E MIN negative num Input DE 16 bit signed number Output DE 8 128 E 128 128 lt DE 8 127 E DE 8 H 127 lt 8 E 127 Ck ck ck ck kk ck ck kk ck ck ck kk kk ck ck ck kk kk ck kk ck ko ck ck ko ck kk ck ko ck kk ck kk ck ko ck kk ck ko Sk ko Sk ck ko ck ko Sk Sk A ko ko ko PX TO PTRN POS push hl HL used to test magnitude sra d 16 bit shift left EE e Sra d rfr e sra d x3 or e bit 7 d Is result negative jr nz NEGTV ld hl OFF80H Is result gt 128 add hl de pop hl ret nc 1 07 IF gt 128 then E MAX signed Num ret NEGTV 1 h1 00080H add hl de pop hl rec 1 080 IF lt 128 then E MIN signed Num ret kk kx k kk kk kk PUT FRAME XXkxkok kckckck ck ck k ckckck ck ck ckckck ck eK ck ckckckckckckckckckckck ck ckckck ck k kk Description The names which constitute a frame are moved to the name table in VRAM The upper left hand corner of the
19. 178 INI C WRITER C ee 178 WRITER Sun dore s do AE LM di uM I EL 178 POLER a PoE a 178 SOUND INIT cen A 178 PLAY Rp c e ius e Pe TE 178 SOUND MAN auc 178 178 EO AE 178 RAND NEN REOR sacha 178 XDHENDDS nA foi tr det eR CR Rilo 179 DS 7 VN 3 D 180 GLOBAL OS 7 SYMBOLS s6ss p2essessavssovsasconsdssvassoazespaoossu don vbsevesessntashbvvbosdeavontagesebecsseiauadevsossonessSaiigeres 181 SYMBOLS IN ALPHABETIC ORDER ttt ttt ttt toto 181 SYMBOLS ORDERED BY ADDRESSES ttt ttti 182 MEMORY MAPS S onus eM E M Ku LM M CE E M 183 COLECOVISION GENERAL MEMORY 183 GAME CARTRIDGE 44 411 t tarata e 183 COMPLET OS 7 secte 184 OS 7 AND EOS SIMILARITIES ettet tnter 185 780 PORTS 55 5 4420 2 2 1 0 1 186 GAME CONIBODPERSE 252 tu ca NM eh M ee 187 CONTROLLER CONFIGURATION
20. A D AS MEE 140 UPDATE SPINNER Cu somete mm dut Ut ean 141 S LR MU M 141 POLRER RA bond c C MEUM LN M M M M IU 142 KBD DBNGE E M 144 ETRE DBNCE ei neer a teats M C SM LUMINE LL DEM A yal 144 cene v AR Rs E M E A M MN LM 145 ARM S aen AM ELM E EU 146 DISPLAY Meade ME 147 DISBLAYSTOGQD d decease LEE 147 NUMBER aoa 151 LM M M EM 151 RIBERA Nu uel sr d LN E d 152 MODE E tue ou dee Lu M D E tutt Ed 153 LOAD ASCI EL LM cum Me er enti 153 GAMK OPTIONS Sesat caes Ree a cs ADAM eA NE MeL C 155 ec M deu ni 155 E 158 INED TABLEO ich cres tro aU LR er M eed 158 GET Vs S Ln MAD pu LM ans Tg po tue gus 159 GEICVRANE A nct ud ecdesia anid Sate T 160 PUTCURAMO A E CE Pct E EE 161 UTS VRAM ae cn a ee AA E aN LE a Ran 162 INIT SPR ORDER Oia as aan a a et ben ti agen cet La 162 INIT SPR ORDER lE
21. ck ck Ck ck Sk Ck Ck Sk Sk Ck kk Ck ck kk Ck ck Ck Ck Sk kk kk kk Sk kk kk Sk ko ko ko ko DESCRIPTION The position and frame number of each of a complex object s component objects is updated each of the component objects HL B ge METHODE OF COMBINING OBJ Selec Then put object is called for Address of object to be processed Address of object s graphics tables in ROM tor for methode of combining object generators with background generators and number of components Obj ERATORS 1 Object pattern gens ored with background pattern gens 7 colorl of background changed to mobile object s color if corresponding pattern byte not zero 2 Replace background pattern gens with object pattern gens treat color same as 1 3 Same as 1 except color0 changed to transparent Same as 2 except color0 changed to transparent ke che ke ke he he Sk hehe ke e he ke e e ke ke khe he ke he ke e he ke ke he ke Sk e he ke khe he ke e he ke kc he he ke e ke he Sk e he ke e he ke ke he he ke e ke ke ke i PUTOBJ GLB PUTCOMPLEX PUTCOMPLEX Update the frame number and the X and Y location in each of the component object s status areas push bc exx ld h 1x 003H ld 1 ix 002H id a hl inc hl ld C hl inc hl 1 b h1 inc hl ld e 11
22. 000 1 e APSV add hl de call DECLSN dec APSV LSN of byte 9 if psw is zero APSV has timed out jr nz L22 decrement ALEN to s if sweep over call MSNTOLSN reload APSV from APS dec hl point to ALEN 4 of steps in the sweep call DECLSN dec ALEN LSN byte 8 jr 123 add ASTEP to ATN ld a hl MSN ASTEP and OFOH mask LS ld e a E ASTEP O dec hl point HL to ATN dec hl dec hl dec hl 1 1 MSN OFOH 0 add a e MSN A ASTEP ATN 0 Saved in E ld a hl freq or CTRL and 00 mask old ATN 0 freq or CTRL or e OR in new ATN hl a Store updated value back into song data area or OFFH RESET Z flag sweep not over yet jr L22 3 ELSE 123 1 1 000 byte 8 to 0 to indicate end sweep L22 75 UTILITY IDENT UTIL includes UPATNCTRL UPFREQ 7 DECLSN DECMSN MSNTOLSN ADD816 PT IX SxDATA LEAVE EFFECT AREA SONG IS Globals GLB UPATNCTRL UPFREQ H GLB DECLSN DECMSN MSNTOLSN GLB ADD816 GLB PT IX SxDATA GLB LEAVE EFFECT H GLB AREA SONG IS INCLUDE OSSR EQU 0S 0 equates Defines INACTIVE EQU OFFH FREO EQU 003H SOUND PORT EQU OFFH pOCKCKCkCk ck kckckckckckckckckckck ck ckckck ke ke kkk UPATNCTRL ke ke ke ke KK COMMENT Perform single
23. buffers add pop ld ld call END7 END6 pop pop pop djnz Now the pattern and color generators ar MUST BE T MODI END7 hl a 003H GET VRAM hl de BK CLR BK PTN hl de de iy 00001H 004H GET VRAM bc hl de DLP2 Color generator table code Divide Y POS 8 A Third of table 0 15 1 2 2 3rd If A 2 Then Y POS 23 And Therefore off DE 256 A 4 NAME Save it Pattern generator table code HL Pattern buffer address Displacement between pattern and color HL Pointer to color buffer Code for color table Restore registers buffers in their respectiv So get the four generators for this frame of the object pop PM8 id add push push ld WORK BUFFER 00006 hl de hl bc e 51 hl d 11 hl WORK BUFFER bc OBJ 24 hl bc hl bc bc 00005H D LT 70H Restore graphics pointer NEW GEN PTRN POINTER HL Address of graphics A FRM 4 X2 Frame pointers start at this offset HL Points to FRAME POINTER for frame DE Address of frame names HL Buffer base address Use location for last GEN to store names Save for later use Save offset Then names are in VRAM 120 PM9 DLP4
24. 0 MSN or b MSN MSN id hl a HL MSN MSN ret 77 kc kc ke ko koe e ke ke ke ke KK ADD816 pOCKCKCkCk ck kckckckckckckckckckckckc kc kc ke ke ke ke kk COMMENT Adds 8 bit two s complement signed valu passed in A to the 16 bit location pointed to by HL i B for positive value A extend sign bit thru B and set Carry store result into LSN 16 bits number B is O or FF to LSB 16 bit number ADD816 id b 000H bit 7 a if is positive jr z POS skip ld b OFFH is neg POS add a hl do 8 bit add ld hl a inc hl put MSB ld a hl into A adc a b MSB Carry ld hl a store result into MSN dec hl re point HL ret MM p PT IX TO SxDATA COMMENT SONGNO passed in Point IX to byte RET with both DE HL pointing to i PT IX TO SxDATA IX amp DE addr of byte 0 in SONGNO B 0 in SONGNO s song data area and IX pointing to SxDATA MSB SxDATA entry in LST OF SND ADDRS s song data area HL pointing to MSB SxDATA entry in LST OF SND ADDRS point HL to start LST OF SND ADDRS HL for addition 4 SONGNO in C HL pts to SxDATA s entry in LST OF SND ADDRS move addr SxDATA to IX thry DE ld hl PTR TO LST OF SND ADDRS dec hl init dec hl Ld cb from id b 000H rig hl bc 1 1
25. 113 214 200 SPRITE 8x8 SAMPLE Pattern Codes Spaceship Color 18 99 99 BD ET ET BD 3C om SPRITE 16x16 SAMPLE Color Code 4 Face Pattern Pattern Codes Face Color 0 00 00 Color Code 0 03 EO A 0 OF F8 0 19 CC 0 36 B6 0 3F FE 0 FF 0 FF 0 FF 0 70 07 0 30 06 0 38 OE 0 3c 0 OF F8 0 03 EO 0 00 00 This sprite pattern is coded like this in the video memory VRAM 00 03 OF 19 30 JE TE 70 30 38 OE 03 00 00 E0 F8 CC B6 FE FF FF FF 07 06 OE 3C F8 EO 00 201 CHARACTERS From Daniel Bienvenu s CV programming documentation The characters also named names in the official coleco documents are normally used as a background or semi mobile objects the letters numbers and symbols are characters A character is 8x8 pixels sized except for screen mode 1 where a character is only 6x8 The characters can be copied many times on screen but only at specific positions Normally there are 768 spaces 32 columns x 24 rows on screen where characters can be placed except for screen mode 1 40 columns x 24 rows VIDEO MEMORY FOR CHARACTERS The names of the three tables in Video RAM for characte
26. output CH1 attenuation and frequency ld a SRIATN OFF format OFF byte into A ld C SRIATN format MSN C for CH1 attenuation ld SR1iFRQ format MSN D for CH1 frequency 1 TO 5 ON 1 point IX to byte 0 data area of song for call TONE OUT E output CH2 attenuation and frequency ld SR2ATN OFF format CH2 OFF byte into A ld C SR2ATN format MSN C for CH2 attenuation ld SR2FRQ format MSN D for CH2 frequency 1 TO S ON 2 point IX to byte 0 data area of song for CH2 call TONE OUT output CH3 attenuation and frequency ld SR3ATN OFF format CH3 OFF byte into A ld SR3ATN format MSN C for CH3 attenuation ld SR3FRQ format MSN D for CH3 frequency ld TO S ON 3 point IX to byte 0 data area of song for CH3 call TONE OUT H output CHO noise ATN and CTRL if different from last time ld SRNATN OFF format OFF byte into A ld C SRNATN format MSN C for CHO attenuation 1 TO 5 0 point IX to byte 0 data area of song for CHO ld e ix 000H look for inactive code OFFH inc e this sets 2 flag if E OFFH 86 H if jr out jr H ELSE call ld and ld 2 if jr ld ld call L6 ret TONE OUT id inc If jr out jr gt ELSE L7 call call L8 ret psw is zero nz L5 SOUND PORT a L6 UPATNCTRL a ix 004H 00 hl SAVE CTRL 11 psw is nzero z
27. strobe before read read routine CONTROLLER 0 If controller lt gt 0 READ1 then read player 1 0 PORT else read player 0 Input H Controller number Output A Raw data CONT READ ld a h jr nz CONT in a _ jr CONT READX CONT READI in a CTRL 1 PORT CONT READX cp re l t Controller scanner CONT SCAN in cp in cp ou ca a CTRL 0 PORT 1 S0 C0 a CTRL 1 PORT 1 50 C1 t STRB Si ll DELAY complement data so data 1 routine Read segment 0 both players ET PORT Strobe segment 1 wait 10 microsecs 140 in 0 PORT 1 1 51 0 1 PORT 1 1 51 1 out STRB RST PORT a ret Update spinner switch routine UPDATE SPINNER in a CTRL 0 PORT ld hl SPIN SWO CT bit 4 a jr nz UPDATE S1 Then UPDATE S0 bit 5 a jr nz UPDATE Then dec hl jr UPDATE S1 UPDATE RO inc 1 51 a 1 PORT bit 4 a JE nz UPDATE SPINX inc hl Check direction bit jr nz UPDATE Then go dec hl jr UPDATE SPINX UPDATE R1 inc 1 A UPDATE SPINX ret Decoder routine Read segment 1 both players Reset to segment 0 Get d
28. the inter interrupt The cartr rupt the cartridge must place the address of his her handler in the IRQ INT VECT location in cartridge ROM idge programmer is responsible for saving any registers his her own interrupt handlers may use and for re enabling interrupts if he she needs to be re enabled IRQ INTERRUPT I IRQ INT VECT RANDOM NUMBER GENERATOR PLACED ERE FOR PURPOSES OF COD Fl COMPACTION Random number generator pseudo for a 16 bit value This routine exclusive or s the 15th and 8th bit together It then rotates the entire quantity to the left and inserts the exclusive or ed bit into the rightmost bit Upon leaving it stores the random number in a specified memory location The random number can be accessed from the global location RAND NUM or the HL pair or the Accumulator 67 RAND GEN ld hl RAND NUM bit 7 h jr z NOT ON bit 0 h jr z SET jr RESET NOT ON bit 0 h jr z RESET SET scf JE CARRY READY RESET CARRY READY rl l rl h ld RAND NUM hl id a l ret filler 0059 db OFFH OFFH OFFH OFFH OFFH db OFFH OFFH OFFH OFFH OFFH db OFFH OFFH THE NMI VECTORING SOFTWARE AND DEFAULT HANDLER When an NMI is raised by the VDP in the ColecoVision system it causes the CPU to restart to
29. Check if already free If so then just reset Set current timer to free Check for repeating timer If not then go free it Check also for long timer If not long then go free it release timer data before freeing it LONG Els in D HL should countain timer to delete addr Get next after mode byt into DE Save them for later Save beginning of table End of table Free If so we don t want it Repeating and long If NOT we don t want it don t want it if larger change it If so we However Smaller If so we Error if Setup HL don t want it equal for SUBSTRACT 4 Reduce this addr By 4 Replace reduced addr Back where we got it Now we can get next timer 134 CLEAR CARRY Get addr of timer to delete Find 4 of bytes to move by substraction Save in counter reg Copy into HL Find source addr Move it next available by 4 from LDIR dest from source of LDIR saves instrs Reset repeat bit just in case inc hl inc hl inc hl push hl jr NEXT MOVE IT ld b 000H hl pop de push hl ld hl NEXT TIMER DATA BYTE sbc hl de id Cpl 1 1 1 h d inc hl inc hl inc hl inc hl ldir 1 bc 00008H Adjust sbc hl bc or 8 ld NEXT TIMER DATA BYTE hl pop hl FREE SET RES LONG HL FREE EXIT ret Procedure Request Signal HL p
30. From Daniel Bienvenu s CV programming documentation The sprites are easy to use because you can place them anywhere on screen Each sprite can be identified like a layer on screen Normally the size of a sprite is 16x16 but there is also the 8x8 format The limits for using sprites are never more than 4 sprites in a row on the same scan line and never more than 32 sprites on screen at the same time All sprites can be magnified by 2 by changing size of the pixels in sprites To display a sprite on screen you need a vector of 4 bytes Position Y Position X Pattern and Colour in the right video memory location SPRITES COLOR The bits 0 are already replaced by the transparent color so there is only one color per sprite To use more than one color you have two solutions Use more than one sprite one for each color combination of sprites and characters SPRITES LOCATIONS ON SCREEN The Y location of a sprite can be any values between 0 and 255 except 208 The special value 208 tells the video chip to stop checking for sprites to display on screen If you want to not show sprite 1 but you want to show sprite 2 use a value like 207 for the Y location of sprite 1 SPRITES PATTERN 8x8 SPRITE A 8x8 sprite looks like a character in screen mode 0 but all bits 0 are colored with the invisible color 0 16x16 SPRITE A 16x16 sprite is a combination of four 4 8x8 patterns These patterns are displayed like this
31. HL 2PTRN GNRTRS 1 SAVE FOR RESTOR SIGNAL PTRN GEN FILL BC 7HL FIRST GEN NAME DE HL HL FIRST NAME NUMGEN HL FIRST GEN NAME NUMGEN 1 8 95 sra sra or sbc inc push pop pop add add add pop add id call pop hl de nl hl hl hl hl hl hl hl bc hl bc a 004H PUT VRAM ar 7D C lear carry E FIRST GEN NAME 8 T HL F_G_N NMGN 1 8 F_G_N 8 1 NUMBER_COLR GENS PR estore reg Step over PTRN GNRTRS HL gt COLOR GNRTR SOURCI SIGNAL PTRN COLOR TBL E IX STACK Internal routine to initialize X POS OLD SCREEN INIT XP OS push pop push INIT 80 db OS IN VRAM ld ld call SM BY OLD pop inc ret bc iy de e 11 hl d 1 nz SM BY OLD a d 070H c OS IN VRAM 080 de a SM BY OLD 080 hl INIT 80 bc 00001H VRAM WRITE de de Pl SAV DI 2 70 SINIT X ONE Y gt STATUS gt 5 EN ADDRESS E OLD SCRE OLD SCRN LD SCREEN T BYTE E gt GRAPHICS gt 5 GEN NAME IN CPU ROM PAT POS TO MOVE IN VRAM 80H VRAM to setup Ptrn VRAM amp Color Gen SUP GEN push push push pus
32. Reg Write in accessing the VDP registers E In addition to the BC pair Reg Write also makes use of AF x Procedure Reg Read Reg Read reads the VDP status register and returns its contents H in the A register It uses no other registers NOTE While this routine has no side effects with respect to the CPU it should be used with caution since reads to the status register have th ffect of resetting the VDP interrupt flag and may cause field interrupts to 2 missed Procedure Vram Write Vram Write takes pointer to the beginning of the data buffer in the A HL pair the VRAM destination address in the DE pair and a byte count in the BC pair It writes the specified number of bytes from the buffer to VRAM Starting at the destination address The AF BC DE and HL register pairs are all affected F NOTE This procedure is not re entrant Procedure Vram Read Vram Read takes a pointer to the beginning of the data buffer in the HL pair the VRAM source address in the DE pair and a byte count in the BC pair It reads the specified number of bytes into the buffer from VRAM starting at the destination address 164 Define DATA PORT EQU OBEH CTRL PORT EQU OBFH External EXT PARAM _ Common PARAM AREA DEFS 6 Global GLB DATA PORT CTRL PORT GLB REG WRITE P GLB WRITE VRAM WRITE VRAM _
33. 31 PUTSEMI DESCRIPTION Puts semi mobile objects on screen A semi mobile object is a box of names characters that can be positioned anywhere on screen FUNCTION S Itcalls PX TO PTRN POS and CALC OFFSET to calculate the top left current screen XY position of the box of chars in RAM Checks if chars that will be overwritten must be saved OLD SCREEN in Semi Object Table If Yes 8000h It recalls the names characters that were overwritten the last time if present from RAM OLD SCREEN and put them back on screen It calls GET BKGRND to save the names characters that the new box will overwrite in RAM again 3 word in Semi Object Table It finally writes new box of names characters on screen by calling PUT VRAM Notes OLD SCREEN can be in RAM 7100h to 7FFFh or in VRAM 0000h 3FFFh Be sure to use the ranges of addresses specified here possibilty of problems If using for OLD SCREEN it uses the WORK BUFFER 8006 pointer for temporary storage Else gt 8000 Only write new box of names characters on screen by calling PUT VRAM 32 PX TO PTRN POS INPUT DE signed 166 number FUNCTION S Devides DE reg by 8 If signed result gt 127 then E max signed positive number 127 If signed result 128 then min negative number 128 OUTPUTS E except if DE 8 lt 128 or DE 8 gt 127 then E equals respectively 128 or 127 CALLS None CALLED BY PUTSEMI PUT MOBILE NOT
34. BK E LD HL WORK BUFFER LD DE YP_BK 1 ADD HL DE LD BK D E IY XP BK LD BC 303h PUSH IX CALL GET BKGRND POP IX PUSH IX 7 CALL PM2 POP Ix z LD 3 LD A IX 6 LD B A AND A 7 7 A JR NZ THREE GEN 10 IY 4 LD A B SRL A SRL A SRL A D E A LD 0 Save another copy of object pointer Call rest of OS PUT MOBILE routine Restore object pointer Set up for 3 item VRAM write Get FIRST GEN NAME And save another copy Evaluate MOD 8 Else mov If not equal 7 then 3 generators to move 4 generators m F A FIRST GEN NAMI Divide by 8 DE gets pointer to object s color gens in VRAM PUTMOBILE version PUTMOBILE The calling sequence for mobile objects is LD HL WORK_BUFFER 88h PUSH HL LD A HL LD 8 3 INC HL D HL A DJNZ POP HL LD A 4 JP PUT VRAM GRAPHICS MODE II LD IY WORK BUFF SET 7 B LD IY FLAGS B PUSH HL LD H IX 3 LD L IX 2 LD A HL LD IY FRM A XOR 80h D HL A INC HL D E HL C 5 D A 8 LD IY XDISP A INC HL D D HL ALL PX TO PTRN POS D IY XP BK E NC HL D E HL D E N D N D A Li 7 IY YDISP A HL D HL CALL PX TO PTRN POS LD BK E LD HL WORK BUFF LD DE YP_BK 1 ADD HL
35. CHK SEG 11 POLLI Jg Decode routine for segment 0 a ix 001H 7 z POLLER X b a de 2 NUM DEV iy de de PLYR 1 ix de SEG 0 z CHK SEG 11 50 C1 hl SPIN SW1 CT DECODE 0 Input A Data Device status byte for current player Address of spinner data Pointer to controller memory B HL IX ECODE 0 ECODI ad Decoder routine for segment 1 OX ret Pointer to debounc JOY b z DEC FIR m Fl JOY DBNCI a C FIR gt FIRE DBNCE a C SPIN b z DECODE OX hl a ixtSPIN ix SPIN a a Input A Data Device status byte for current player Pointer to controller memory ECODI B IX IY 1 ld bit Pointer to debounc ARM b Get Player 1 status If player 1 is not active Then exit all done Else player 1 is active Save player 1 status Compute address of debounce buffer for player 1 Compute address for player 1 If segment 0 is not active Then check segment 1 of CONTROLLER MEMORY Decode data for segment 1 Restore status for player 1 If segment 1 is not active Then exit all done Else segment 1 is active Decode data for segment 1 status buffer Save data If joystick not active Then check fire bu
36. Else state 0 Get current data If old new Then saw data twice in sequence Else first time save current data Set state 1 Save in controller memory 2joy Get current data If old new No change in state Else save current data Set state 0 146 DISPLAY LOGO Description Displays the Coleco logo screen with COLECOVISION on a black background The game title manufacturer and copyright year are obtained from the cartridge and overlayed onto the logo screen The logo is then displayed for 10 seconds after which time a jump to the game start address is executed If no cartridge is present a default message is displayed instructing the operator to TURN GAME OFF BEFORE INSERTING CARTRIDGE OR EXPANSION MODULE 0 1982 COLECO This message is displayed for 60 seconds the screen is then blanked and finally a soft halt is executed locking up the program until the unit is reset DISPLAY LOGO exists with the VDP in mode 1 the screen blanked and the ASCII character set in VRAM The memory map is as follows VDP MEMORY MAP 3800H 3FFFH SPRITE GENERATOR TABLE 2000H 201FH PATTERN COLOR TABLE 1BOOH 1B7FH SPRITE ATTRIBUTE TABLE 1800 PATTERN NAME TABLE 0000H 17FFH PATTERN GENERATOR TABLE 2 External EXT
37. M ada 162 S P ue qu 163 WRSPR NM THE A etica p Ee Me cR 163 DRIVERS POR VDO pe tu P 164 REG WRITE Q amenena io ea ue e Ee 165 BEG WRITES Mace A M E D DL 165 WRITE CM AE 166 VRAM WRITE a rae nak 166 READ VRAM O Me LI 167 VRAM READ enc Seu E LLL C ERU dur 167 REG READ e c es di 167 GRAPHICS PRIN PRG ant D E oak 168 VERT M ee dU eO LT MR RAE ME 168 RPLCT ue Mec ace a Ar 168 ROI S ite S aee i D eu E Me te D MEM AM DE E 169 ENIRO ee Re HUM tU MOI n E E NOLO 169 EXPANSION ROUTINES Ae Ed 173 MAGNIEESS A cet dM M AM Ma te eh M E MEE MON 173 78 07 15 3817 B Paes 174 MIRRORROTATE REN usat Dag Caper ovis Ters ala 175 175 ROLA
38. NUM B4 1EM 0 0 B4 111 1 1 1 11010 FC TET 110 0 CC 111 100 CC 11 aN i No 78 Screen Mode 2 Character Sample A 8x8 character pattern that use two colors per line Pattern Spaceship Colors Codes Bits 1 Codes Spaceship Pattern Hj Dd Ed Dd Dd Dd p 1 203 COLECO ASCII TABLE DEC 0 63 HEX 00 3F DEC HEX CHARACTER DEC HEX CHARACTER 0 00 32 20 Space 1 01 33 21 2 02 34 22 3 03 35 23 4 04 36 24 5 05 37 25 6 06 38 26 amp 7 07 39 ET 8 08 40 28 9 09 41 29 10 0A 42 2A 11 0B 43 2B 12 0 44 20 13 0 45 2 14 OE 46 2E 15 47 2 16 10 48 30 0 17 11 49 31 1 18 12 50 32 2 19 13 51 33 3 20 14 52 34 4 21 15 53 33 5 22 16 54 36 6 23 17 55 27 7 24 18 56 38 8 25 19 57 39 9 26 1 58 3A 27 1B 59 3B 28 60 3C lt 29 ID 61 3D 30 1E T 62 3E gt 31 M 63 3F 204 DEC 64 127 HEX 40 7F DEC HEX CHARACTER DEC HEX CHARACTER 64 40 96 60 65 41 97 61 66 42 B 98 62 b 67 43 C 99 63 68 ed D 100 64 d 69 45 E 101 65 e 70 46 F 102 66 f 71 47 103 67 g 72 48 H 104 68 h 73 49 I 105 69 1 74 4 J 106 6A 1
39. nz TRANSP 10 Reflets 8x8 pixel block arround the horizontal axis pointer Destroy AF BC DE HL EFI id add inc LOOP ld ld inc dec dec ld or jr ret bc 00007H hl bc bc a hl de a de hl bc a b nz REFLECT LOOP Modified february 14 1983 Filler locations were changed to to reflect OS 7PRIM db db db db OFFH OFFH OFFH OFFH Destination pointer ES JUMP TABLE This is the jump table to be used in accessing code residing in the OS ROM This table must have its origin redefined to account for growth Pile new routines at the beginning of the table making sure to increment the NO OF ROUTINES value NOTE NO DELETIONS SHOULD BE MADE FROM THIS TABLE Define ROM END EQU 2000H This is the end of OS ROM NO OF ROUTINES EQU 53 This number keeps count of the number of routines accessed through the jump table Origin JUMP TABLE ORG ROM END NO OF ROUTINES 3 PLAY SONGS jp PLAY SONGS S1F61 See page 86 ACTIVATEP jp S1F64 See page 93 PUTOBJP jp PUTOBJQ 81 67 See page 102 REFLECT VERTICAL jp RFLCT VERT 1F6A See page 168 REFLECT HORIZONTAL jp RFLCT HOR 51 60 See page 168 ROTATE 90 ROT 9
40. 000 ld b iy 001H srl h 1 dec a jr nz DIVIDE ld ey call REG WRIT ret FACTORS db 007 005H db 00BH db 006H db 00AH db 002H db 00BH db 004H db 006H db 003H GET VRAM P dw 00005H dw 00001H dw 00001H dw 00001H dw OFFFEH dw 00002H GET VRAMQ ESS TABLI E COD E ADDR E ADDR START INDEX BYTE SLICI ESS FACTOR ER VAR_DATA BUFFER ITEM COUNT INTEG 159 BYTE ld bc GET VRAM P 1 de PARAM AREA call PARAM ld a PARAM AREA ld de PARAM AREA 1 ld iy PARAM AREA 5 ld hl PARAM AREA 3 Desc Gets a certain number of bytes from VRAM and puts them in a buffer Input TABLE CODE in A O SPRITE NAME TABLE H 1 SPRITE GENERATOR TABLE 2 PATTERN NAME TABLE 4 COLOR TABLE START INDEX in DE DATA BUFFER in HL COUNT in IY call SET COUNT call VRAM READ ret SET COUNT Desc Called by PUT VRAM and G Sets byte count and index and reads to and from VRA TABLE BYTES ITEM SPRITE NAME 4 SPRITE GEN 8 PATTERN NAME 1 3 8 COLOR MODE 1 1 H CO
41. 000 050H 050 OF8H 050 020H 078 OAOH 070 OCOH OC8 010 020 040H OAOH 040 020H 020 020H 000 020H 040 080H 080 020H 010 008H 008 020H 0A8 070H 020 000H 020 020H OF8 000H 000 000H 000 000H 000 000H OF8 000H 000 000H 000 000H 008 010 020 070H 088 098H 0A8 020H 060 020H 020 070H 088 008H 030 OF8H 008 010H 030 010H 030 050H 090 OF8H 080 OFOH 008 038H 040 080H OF8H 008 010 020 070H 088 088H 070 070H 088 088H 078 000H 000 020H 000 000H 000 020H 000 010 020 040H 080 000H 000 OF8H 000 040H 020 010 008 070 088 010 020 070 088 OA8H 088 020H 050 088H 088 OFOH 088 070H 088 080H 080 OFOH 088 088 OF8H 080 080H OF8H 080 080H 078H 080 080H 080 088 OF8 070H 020 020H 020 008H 008 008H 008 088H 090 OAOH OCO 080H 080 080H 080 008 OA8H OA8 088H 088 OC8H OA8 070H 088 088H 088 OFOH 088 088H 070H 088 088H 088 000 oco OF3H OA 00 I 00 02 00 OF 028H D O oO OA8H 000 080 008 070 020H 020H 000 000 040 0C8H 020H 040H 008H OF8H 008H 088H 040H 088 008 020 020 040H OF8H 010 020 0 0 OF8H 088H 080 088 080 080 098H 088H 020 008 0 080 088H 098H 088H 080H OA8H 151 C C3 LX O gt w
42. 1 1 1 1 hl b Store PUTOBJ parameter inc hl ex de hl HEAD address in DE ld a QUEUE HEAD 99 inc a new HEAD in A If QUEUE HEAD QUEUE SIZE then id hl QUEUE SIZE cp h1 jr nz NOT_TOO BIG QUEUE HEAD 0 ld a 000H ld QUEUE HEAD a If HEAD ADDRESS BUFFER ld hl BUFFER ld HEAD ADDRESS hl jr SET_UP_ENDIF Else NOT TOO BIG Store new QUEUE HEAD id QUEUE HEAD a Store HEAD ADDRESS 1 HEAD ADDRESS de End if SET UP ENDIF ret Procedure INIT QUEUE SIZE BYTE VAR A QUEUE QUEUE SIZE Destroys A INIT QUEUE P dw 00002H dw 00001H dw OFFFEH This is the parameter descriptor for INIT QUEU Begin INIT QUEUI INIT QUEUEQ passed in A LOCATION passed in HL ld bc INIT QUEUE P ld de PARAM AREA call PARAM ld a PARAM AREA id hl PARAM AREA 1 INIT QUEUE QUEUE SIZE ld QUEUE SIZE a QUEUE HEAD ld a 000H ld QUEUE HEAD a ld QUEUE TAIL a BUFFER TAIL ADDRE id BUFFER hl ld HEAD ADDRESS hl ld TAIL ADDRESS hl End INIT QUEUE ret RITER Procedure W Takes no parameters Destroys ALL Begin
43. 2 2 2 1 b 001H ld c 080H call WRITE REGISTER SOFT HALT jr SOFT HALT KKEKKKKKKKKKKKKKKKKKKKK KK KK Mo DATA TABLES Cck ck ck ck ck ck ck ck ck ckckckckck ck ck ck k ck ck kk COLOR NAME TABLE LOGO COLORS db OOOH OOOH OOOH OFOH OFOH OFOH OFOH OFOH db db OFOH OFOH OFOH OFOH ODOH 030H 040H PATTERN NAME TABLE LOGO NAMES COPYRIGHT 060H 061H 068H 069H 070H 071 db 089H 064H 065H O6CH 074H 075H db 062H 063H 06 O6BH 072H 073 db 066H 067H O6DH 076H 077 S TURN GAME OFF db TURN GAME OFF S BEFORE INSERTING CARTRIDGE db BEFORE INSERTING CARTRIDGE S OR EXPANSION MODULE db OR EXPANSION MODULE S C 1982 COLECO db 1982 COLECO 01DH TRADEMARK db 01 01 PATTERN GENERATOR TABLES GEN db 000H OOOH OOOH 000 000 db 07FH OFFH OFFH db 000H 080H OCOH OCOH OCO db 03FH 07FH OFFH OFFH OF3H OF3 db 000H 080H OCOH OCO db OFOH OFOH OFOH OFOH OFOH db OFFH OFFH OFOH OFF db 000H 000 000 db 0 OF1H 07BH 07BH 078
44. COM PAT COL bit jr or ld ld or ld ld or ld ELSE ELSE18 Ck ck kckck WORK BUFFI hl WORK de YP_BK 1 hl de e 1y XP d iy YP be 00303 PUT FRAM LE oun END OF PUT MOBILE PAT POS for the object Test for valid OLD SCREEN data Then there is valid data Test if OS position same as current position Clear the carry Is there any difference Then position has changed Get buffer bas Point to OLD SCREEN names DE X YPAT POS BC X and Y EXTENT HL Buffer base addr Point to names for object DE A and Y PAT POS BC X and Y EXTENT 3 1 contain 24 bit pattern to be combined with background IX points to the 1st of 3 generator bytes to be combined 0 1y FLAGS PSW IS ZERO nz ELSE18 ix 000H 1 000 ix 008H ix 008H a 1 ix 010H 1 010 END18 a PSW IS NZERO gens or replace Then OR left byte with background Substitute for that generator byte Now do middle byte And now the right hand byte Replace background with non zero bytes Is byte non zero 126 END19 END2
45. DE LD D IY YP BK D E IY XP BK LD BC 303h PUSH IX CALL GET BKGRND POP IX JP PM2 R LD HL GRAPHICS LD B MODE CALL PUTMOBILI Call rest of OS PUT MOBILE Point to 4 gen Save pointer Copy this generator 3 times Get back pointer Code for color table routine LD IX HIGH LEVEL DEFINITION 057 ROUTINES SPECIFICATIONS Written by Daniel Bienvenu and Steve B gin Verified and completed with the ColecoVision programmers manual in progress SOUND ROUTINES Except TURN OFF the sound routines in the jump table require a specific sound data format and or sound tables in RAM and ROM More information about the sound format song data areas and more at the sections SOUND DATA FORMAT SOUND TABLES SONG TABLE IN ROM OUTPUT TABLE IN RAM in pages 190 192 A quick reference guide is available in page 22 FREQ SWEEP INPUT IX address of byte 0 of a song data area FUNCTION S If frequency not swept so decrement NLEN note length value and RET Otherwise Decrement FPSV counter If FPSV timed out then Reload FPSV counter and decrement NLEN value Add frequency step FSTEP to frequency value FREQ if note not over OUTPUTS Z flag is reset if sweep in progress or note not over Z flag is set if note over CALLS DECLSN MSNTOLSN ADD816 CALLED BY PROCESS DATA AREA NOTES None ATN SWEEP INPUT IX address of byte 0 of a song dat
46. EUI QUEUE TAIL TAIL ADDRE Restore stack poin Store new QUEUI E SIZE BUFFER Cer E TAIL I TAIL ADRE 55 End if TAIL ADRESS 3 Restore deferal flag GI PUTISPRIT 101 PUTCOMPLI Procedure PUT OBJP VAR DATA BUFFER PARAM BYTE This is the PASCAL entry point to the PUT OBJ routine Input IX BUFFER B PARAM PUTOBJQ ld bc PUTOBJ PAR ld de PARAM AREA call PARAM _ ld ix PARAM AREA id a PARA AREA 2 1 PUTOBJ ld a DEFER WRITES Check if defered write is desired cp TRUE jr nz DO PUTOBJ If not process object call UP WRITE so set up for defered write ret DO PUTOBJ ld h 1 001 Get address of graphics for OBJ n ld 1 ix 000H id a hl A OBJ TYPE id SAVE COPY in C and OOFH Mask for OBJ TYPE number jp z PUTSEMI 0 SEMI MOBILE dec a jp z PUT MOBILE 1 MOBILE dec a jp z PUTOSPRITE 2 SPRITEO dec a jp z PUTISPRITE 3 SPRITE1 PUTCOMPLEX H 4 COMPLEX 102 PUT SEMI kc ck kc ke ke ke koe e ke ke KK Description Input GLB PUTSEMI ld ld push pop PUT Si EMI Puts semi mobile objects on screen IX Address of object to be processed HL Ad
47. PM10 push a d 070H ELSE8 READ VRAM END8 de hl iy WORK BUFFER bc iy bc a 1y 004H iy WORK BUFFER iy COLR a de hl WORK BUFFER bc OBJ PTN hl bc b 004H a de 1 001 IF PSW IS CARRY jr exx add add add id id add push exx pop ex push id ldir pop ex jr ELSE sub exx add add add id id add push exx pop nc ELSE9 a a a a a a l a h 000H hl bc hl de de hl bc bc 00008H bc de hl END9 Nam ix 001H a a a a a a l a h 000H hl de hl de IF D LT 70H jr a d 070H nc ELSE10 Get the 4 names Names in CPU memory space Get color byte Offset to 1st name A Color Byte COLOR Color Byte DE Address of 1st name in buffer HL buffer base address Start of object s pattern buffer Get 4 patterns corresponding to the 4 names Get name Compare to NUMGEN Save pointer to names The name lt numgen therefore Pattern part of graphics tables 8 Name HL Pointer to Pattern Number of bytes to move therefor gt Numgen not part of ROMed Gens Substract Numgen from NAME 8 NAME HL Pointer to pattern Then pattern in VRAM 121 push push push ld call 1 pop add pop jr ELSE ELSE10 push ld ldir pop
48. VRAI EXT GAME NAME EXT WRITE REGISTER EXT COLORTABLE EXT START GAME Define DATA PORT EQU OBEH CTRL PORT EQU OBFH CARTRIDGE EQU 08000H Global GLB 5 TBL Pointer to uppercase ASCII generators GLB NUMBER TBL Pointer to 0 9 generators GLB DISPLAY LOGO Display COLECOVISION logo GLB LOAD ASCII Load PATTERN GEN TABLE with full ASCII set GLB FILL _ Fill VRAM with a value GLB MODE 1 Set up MODE 1 graphics DISPLAY LOGO ld h1 00000H 147 1 de 04000H 1 a 000H call FILL call MODE l1 call LOAD ASCII ld hl OBJ TABLE ld de 00060H WRITE LOOP push hl push de ld a hl cp jr z DONE LOGO ld b a inc b ld hl LOGO GEN 1 de 00008H ADDR ADJ djnz ADD 8 pop de push de 1 00001 1 a 003H call VRAM pop de pop hl inc de inc hl jr WRITE LOOP DONE LOGO pop de pop hl jr WRITE NAMES ADD 8 add hl de JE ADDR ADJ WRITE NAMES ld hl LOGO NAMES 1 00085H ld iy 00016H ld a 002H call PUT VRAM ld hl LOGO 5 22 1 de 000A5H ld iy 00016H id a 002H call PUT VRAM ld hl TRADEMARK ld de 0009BH ld iy 00002H 1 a 002H call VRAM SET UP DEFAULT COPYRIGHT MESSAGE id hl S C 1982
49. check for end of song data areas jr Z DONE SNDMAN leave loop if all data areas checked if area active set appropriate channel data area pointer cp INACTIVE check for inactive data area don t up date ptr if so if PSW IS ZERO area is active update channel data ptrs jr z L9 ld ix 000H get in A and OCOH B7 B6 in A CH rlca form 2 in A i e the offset from rlca PTR TO S ONO of channel data area pointer rlca that points to channel CH ld e a add offset to addr of PTR TO C ON O 1 d 000H ld hl PTR TO S ON 0 add hl de HL points to proper channel data area pointer push ix store this song data area s byte 0 addr there pop de hl e inc hl 1 hl d point IX to byte 0 next song data area ld 00AH 1 000 JE L2 repeat loop _SNDMAN pop ix restore IX ret ke ke ke ke KK UP CH DATA PTRS See Users Manual for description Terminology SFX address of sound effect routine i PROCESS DATA AREA call AREA SONG IS return area s SONGNO in A and addr SFX in HL cp INACTIVE test for inactive code ret Z RET no processing if area inactive if special effect call it to process the data area cp 0 test for special sound effect jr nz L10 1 007 HL to SFX 7 starting adr of the effect s code ld d 000H add hl d
50. ckockckckckckckockckckckck ld b 001H ld call WRITE REGISTER 156 ret Ck ckckck ck ck ck k ck kk DATA TABLES ck ck ckck ck kck ck ckck kk kk TO SELECT GAME OPTION PRESS BUTTON ON KEYPAD 1 SKILL 1 PLAYER 2 3 4 5 7 8 TWO KKKKKKKKKKKKKKK LOCAL SUBROUTINES INE 1 db INE 2 db INE 3 db INE 4 db INE 5 db INE 6 db INE 7 db INE 8 db INE 9 db INE 10 db INE 11 db INE 12 db WRITE L3 ld ld 1 call ret WRITE L4 jr WRITE L5 JE WRITE L6 WRITE CHAR ld call ret WRITE 111 call ret I WRITE L12 ld ld ld call ret hl LINE 3 iy 00016H a 002H PUT_VRAM hl LINE 4 WRITE_ hl LINE 5 WRITE C hl LINE 6 iy 00001H a 002H PUT_VRAM hl LINE 11 iy 00003H a 002H PUT VRAM hl LINE 12 iy 00001H a 002H PUT VRAM 157 TABLE MANAGER Define TRUE EQU 1 External EXT VRAM WRITE REG WRITE VRAM READ E
51. inc a ld iy YDISP a cp 008H jr 010H jr nz END11 IF11 ld bc 00010H add ix bc END11 inc ix ex af af dec a jr z C LP EXIT ex af af jr COMBINE LOOP C LP EXIT pop hl bit 7 Ly FLAGS IF PSW IS ZERO jr nz END12 id hl WORK BUFF ld bc BK CLR add hl bc id d iy COLR bit Ly FLAGS IF PSW IS ZERO jr nz ELSE13 ld jr END13 H ELSE ELSE13 id ENDIF END13 id b 009H DLP5 ld a 1 and id hl a inc hl djnz DLP5 END12 Save left byte in E Increment YDISP Beginning of next row Point to next gen byte Decrement loop counter POP Pointer off stack Test for mode 1 update mode 1 color Gens a Offset for color buffer HL points to start of color buffer Get object color Color0O background or transparent Then use background 1 Mask for 1 0 of background Mask replace 1 0 with transparent Change all 9 color bytes Get background color gen Mask out colorl Add object colorl Update color generator Point to next color gen Decide which part of object s pattern and color tables to use ld a GEN bit 7 iy FRM IF PSW IS NZERO jr z END14 add a 009H 7 ENDIF END14 Get name of 1st generator in object s table Test which part of table to use use upper half of tables Change names in background buffer to th
52. inc hl id d 1 exx add a a add a a ld e a ld 000 Save selector and component count COMP CNT Use primed regs for X LOC and Y LOC High byte of status Low byte of status FRAME X LOCATION Y LOCATION FRAME 4 FRAME from pointer to frame and offset pointers 128 inc add ld inc id inc ld inc id PUDE Y pop 1 1 srl srl srl srl ld push push push push ld ld inc inc inc inc ld inc ld push pop pop id jr TBLO X Location exx inc nl hl de b hl h b Ipe LOC BC X LOC HL IX Addr of hl BC POINTER TO LIST OF FRAME 0 5 E Jg Point to 1st of FRA OFFSET PNTR pairs Point to FRAME pointer FRAME pointer 5 Offset pointer PNTR TO LIST OF OFFSETS HL FRAME pointer PNTR to frame list DE PNTR to offset list SP COMP CNT amp SELECTOR FOR 0 COMP CNT 1 COMP OBJ N FRAME FRAM COMP OBJ N X LOCA COMP OBJ N Y LOCA N FROM FRAME LIST CMPLX OBJ X LOCATION X OFFSET N CMPLX OBJ Y LOCATION Y OFFSET N bc Get component count into c b Save selector in C a Get count into low nibble a a a b a component count bc Save counter and selector on stack ix Save addr o
53. 08021H This is the non maskable interrupt NMI soft vector GAME NAME EQU 08024H names P NAM From here to START GAM that has the following form OF THIS F there should string of ASCII characters E MAK ER OF THIS GAM E COPYWRITI 65 For example DONKEY KONG NINTENDO 1982 IMPORTANT NOTE IS THE RESPONSIBILITY OF THE CARTRIDGE PROGRAMMER TO PLACE BEER THESE CODES IN CARTRIDGE ROM poc OPERATING SYSTEM ROM CODE PAGE ZERO CONTAINS THE RESTART VECTORS INTERRUPT VECTORS AND THE INTERRUPT VECTORING SOFTWARE AS WELL AS THE DEFAULT HANDLI Ck ck kk ck Ck Ck ko ko ZERO ck ck Ck ck kk ck Ck ck kk Ck Sk kk Sk kk kv Kk KKK KKK KK ERS FOR INTERRUPTS AND RESTARTS IDENT OS includes BOOT UP RAND GEN PARAM Globals 2 GLB BOOT UP RAND GEN PARAM _ Externals EXT TURN OFF SOUND CONTROLLER INIT DISPLAY LOGO INCLUDE OSSR_EQU 0S 0 equates Defines STACK EQU 073B9H DEFER WRITES EQU 073C6H MUX SPRITES EQU 073C7H RAND NUM EQU 073C8H BOOT
54. 1 and one color for bits 0 for each bloc of 8 characters in the character set e Screen mode 1 there are only two colors one color for bits 1 and one color for bits 0 for all the characters These colors set in VDP register 7 e Screen mode 2 there two colors one color for bits 1 and one color for bits 0 per line of 8 pixels for all the characters in the character set For the screen mode 0 and 2 if you want to see the background color set in the VDP register you have to use the transparent color code 202 CHARACTER PATTERN Characters are named names in the official Coleco documents and tiles by some programmers character on screen is defined by a number that represent a pattern in the PATTERN GENERAOR table in VRAM at a specific location in the NAME table in VRAM A character pattern is a 8x8 pixels graphic 6x8 for screen mode 1 CHARACTER PATTERN SAMPLE Screen Mode 0 Character Sample A 8x8 character pattern sample that use only two colors one for bits 1 and one for bits 0 Pattern Spaceship Colors Codes Bits 1 Bits 0 Code 18 99 99 BD E7 E7 BD 3C Spaceship Pattern Screen Mode 1 Character Sample A 6x8 character pattern that use only the colors set in the control register 7 Pattern Spaceship Colors DRE Codes Bits 1 Bits 0 Code UNUS 0 30 El 1 NUM 1
55. 186 GAME CONTROLLERS From Technical Reference Manual The game controller contains an 8 position joystick two push buttons Fire and Arm and a 12 key keypad Remark Extra push buttons Fire 3 and Fire 4 were done after the Coleco bios for the SuperAction controllers it s why they are not decoded by calling DECODER or POLLER The information from a controller is read by the CPU on eight input lines through a single port Once a port has been read the input data must be decoded See CONT SCAN page 140 in OS 7 Listing for details CONTROLLER CONFIGURATION De Ds INT D D Di Do Fire X Common 0 North X Enabled X X By ports East X FD FF S E X X South X S W X X West X N W X X Arm Fire 2 X Common 1 2 X Enabled 3 X X By ports 6 X FC FE 9 X 1 2 3 8 X X X 7 X X 4 5 6 4 X X X 1 X 7 8 9 5 X X 0 X X a i X X X X Fire 3 X X X Fire 4 X X X Spinner A X Always Spinner B X Function presently used in Expansion Mod 2 Remark Dz is named INT in the ColecoVision official documentations including the absolute OS 7 bios listing Note When a spinner is spinning INT bit Spinner A is reset and D bit Spinner B is set or reset depending on the way the spinner is spinning 187 SOUND GENERATOR From Daniel Bienvenu s CV prog
56. 2 SEMI TYPE 0 SEMI MOBIL 2 MOBILE PTYPE 1 MOBILE dec a jp 2 OSPRT TYPE 2 OSPRITE dec a jp 2 15 PTYPE 3 lSPRITE dec a JE 2 CMPLX 4 COMPLEX pop af SUBCASE ELSE ret ON ENTRY TO SUBCASE STACK OBJ TYPE amp SUP VRAM FLG H HL 2OBJ 4 2 DE gt OBJ GRAPHICS 0 E BC gt OBJ 5 05 0 0 93 SUBCASE Complex a de id rra rra rra rra and ld id inc ld inc jr CMPLX4 pop push push push ex call pop pop ld inc ld inc djnz CMPLX9 ACT Si pop ret EMI z CMPLX9 de hl D e 1 d 1 CMPLX4 SUBCASE Semi Mobile SUP FO call ld id inc id id HL FI DE gt N INIT XP OS a de a de 1 005 h 000H At this point STACK OBJ TYPE amp SUP VRAM EN NAME BC FRI R VRA pop jr push SET CNTR i gt ptrs list EMPTY Sup call comp obj Restore pntrs More reloop Clear stack for rtn Technacally should jmp to rtn X PAT POS 80H FIRST GEN NAM 2 NUMGEN NEXT GEN PHL FIRST FIRST GEN NAME NUMGEN
57. 66h The vectoring software for the NMI is identical to that for the maskable interrupt except that it gets its vector from NMI INT VECT instead of IRQ INT VECT Again the cartridge programmer is responsible in his her own interrupt handlers for saving and restoring the processor state when necessary and for cleaning the VDP condition by reading the VDP status register NMI INTERRUPT jp NMI INT VECT OS ROM DATA AREA AMERICA db 60 This byte should be used whenever the cartridge programmer wants to set up real time counters It has a value of 60 for ColecoVisions marketed in the USA and 50 for european untis Use of this byte ensures cartridge compatibility at least where real time counting is concerned ASCII TABLE dw ASCII TBL This is the address of the Rom pattern generators for uppercase ASCII which are contained within the operating system NUMBER TABLE 68 dw NUMBER TBL This is the address of the 0 9 which are contained wit ROM pattern generators for the numbers hin the operating system KEK KKK KKK KEK KKK KKK KKK POWER ON BOOT SOFTWARE KR KKK KKK KKK KKK KEK ko ko ko ko BOOT UP SINCE THE VIDEO GAME SYSTEM MAY BE STARTED UP WITH A GAME CARTRIDGE KEYBOARD MODULE OR BOTH OR N
58. 75 4 K 107 6B k 76 4C E 108 6C 77 4D M 109 6D m 78 4E N 110 6E n 79 4 111 6F 80 50 P 112 70 p 81 51 Q 113 71 4 82 52 R 114 e r 83 53 S 115 T3 84 54 T 116 74 85 55 U 117 73 u 86 56 V 118 76 87 57 W 119 TI w 88 58 X 120 78 x 89 59 Y 121 79 y 90 5A Z 122 7A 7 91 5 123 7B brace left 92 20 124 7C broken vertical 93 5D 125 7D brace right 94 5E D 126 7E 95 5F underline 127 7F 205 GLOSSARY ATN Attenuator LSB Less Significant Byte LSN Less Significant Nibble MSB Most Significant Byte MSN Most Significant Nibble Nibble 4 bit half byte Byte 8 bit Word 16 bit 206
59. AF DE reset to 0 and C equal the input value A FILL VRAM ld 1 1 out CTRL PORT a 152 1 a h 040H out CTRL PORT a FILL ld a c out DATA PORT a dec de id a d jr nz FILL call READ REGISTER ret MODE 1 ld b 000H ld 000H call WRITE REGISTER id b 001H ld 080H call WRITE REGISTER id 002H ld h1 01800H call INIT TABLE ld a 004H ld h1 02000H call INIT TABLE ld 003H ld h1 00000H call INIT TABLE id ld hl1 01B00H call INIT TABLE id 001 1 h1 03800H call INIT TABLE ld b 007H id 000H call WRITE REGISTER ret Desc Writes out ASCII character generators to the pattern H generator table INIT TABLE must be used to set up the table address LOAD ASCII ld hl ASC TABLE Location of generators ld de 0001DH Offset to place ASC TABLE ld iy 00060H in the correct location id a 003H call PUT VRAM id hl SPACE ld 00000H 1 iy 00001H id a 003H call PUT VRAM ret PARSE ld bc 00000H From HL increment BC until P LOOP ld hl HL cp 02FH ret Z 153 ELAY TIMER TIMER ENTER_PRT 10 ld T3 O RHaAaAHKK hl bc P LOOP BC LENS IY items to be transferred in PUT VRAM DE Location of st
60. ANNE AL o Ae t tup 68 9 buie sre 68 ES 69 SOUND ROUTINE 2 73 EREOSWBEP RUM 74 Diva 5 S Se cede a 74 75 RCM CA 75 NN 76 UI er c RE d M RM EE PR UE 76 s sti c hoi EM e A E 76 DEOL SN Rad EM NM 77 pU Lxx AL D i LM I I 77 DESO GN c uM te cas LL a eat MM M EM MM e 77 NN cM MM CUM ME PUES 78 _ IO a DYN V eor sott MU E 78 eo nose eue M 79 AREA SONG cl Sess haha ELM ar P DAN A ME LUN EM 79 SOUND iu uu RM Mu REEL LAE E 80 TINE SOUND 80 NIT SOUND LN C CA UE C 80 wes un UR MR NL M M ME E 81 DOMARE A MM DEM 81 JUKEBOX mM MCN 82 JUKEBOX Q nM LE LUE 82 JUKE BOX a c M pM IMMER D C EM ML act 82 SCOUT
61. B Light Yellow Yellow Light Grey 0 80 0 57 0 17 12 C Dark Green 0 47 0 13 0 23 13 D Magenta 0 53 0 73 0 67 14 E Grey Light Grey 0 80 0 47 0 47 15 White 1 00 0 47 0 47 TMS9928 color palette calculated by Richard Drushel based on the TMS9928 technical documentation TMS9938 color palette calculated by Marat Fayzullin TMS9928 color palette used in MESS emulator The default color palette used in ADAMEM is the one based on the TMS9928 technical documentation The color palette used in COLEM is the one calculated by Marat Fayzullin The color palette I see my Commodore monitor model 1802 looks like the used in MESS emulator More information about Texas Instruments TMS99n8 color palette URL http junior apk net drushel pub coleco twwmca wk961118 html http junior apk net drushel pub coleco twwmca wk961 201 html http junior apk net drushel pub coleco twwmca wk970202 html 197 VIDEO DISPLAY SUMMARY Based The Hackers Guide to and Texas Instrument documentation The VDP displays an image on the screen that can be envisioned as a set of display planes sandwiched together The objects on planes closest to the viewer have higher priority In cases where two or more entities on different planes are occupying the same spot on screen the entity on the higher priority plane will show at that point The first 32 planes each may contain a single sprite Since the coordinat
62. Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 Byte 0 V7 V6 V5 V4 V3 V2 VI Byte 1 1 R2 RO Legend V Value to be writen in the register 7 R Register number 2 ASM 14 a value out Obfh a set value Id a register number add a 80h out Obfh a write value in register COLECO BIOS IFD9 Input C data B register VDP MEMORY ACCESS To read or write video memory data two bytes must be written to set the video memory offset address Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 Byte 0 7 6 5 4 A2 1 0 Byte 1 0 R W A13 A12 10 9 8 Legend A Memory address 13 0 R W Flag is set to write reset to read HL Video Memory Offset ASM ld out 0bfh a low addr Id a h add a 40h write flag out Obfh a hi addr After setting the video memory address simply read or write data through the video data port Obeh The offset address in video memory is auto incremented after each 1 byte transfer COLECO BIOS IFDF Write VRAM DE offset HL pointer to data buffer BC count COLECO BIOS IFE2 Read DE offset HL pointer to data buffer BC count 195 VRAM MEMORY ACCESS DELAY TIMES The amount of time necessary for the CPU to transfer a byte of data to or from VRAM memory can vary from 2 to 7 95 microseconds Once the VDP has been told to read or write
63. COLECO ta de 002AAH ld iy 0000DH ld a 002H call WRITE OUT COLOR NAME TABLE ld hl LOGO COLORS 148 1 00000H ld 004H ld iy 00012H call PUT VRAM ENABLE DISPLAY 1 b 001H ld call WRITE REGISTER CARTRIDGE TEST ld hl CARTRIDGE id a hl cp jr nz NO CARTRIDGE inc hl ld a hl cp 055H jr nz NO CARTRIDGE CARTRIDGE PRESENT DISPLAY GAME TITLE ld hl GAME NAME call PARSE ld de GAME NAME ld h1 00201H call CENTER PRT DISPLAY COMPANY NAME ld hl GAME NAME call PARSE inc hl ld d h ld 1 call PARSE id 1 101 1 11 CENTER PRT CHANGE DAT i id hl GAME NAME call PARSE inc hl call PARSE inc hl ld de 002ACH 1 00004 1 002 11 VRAM DISPLAY 10 SECONDS call DELAY 10 TURN OFF DISPLAY 1 b 001H ld c 080H call WRITE REGISTER 1 hl START GAME jp 1 INFO index jump NO CARTRIDGE ld hl S TURN GAME OFF ld de 001AAH ld iy 0000DH 002H call id 1 5 BEFORE INSERTING CARTRIDGE ld de 001E4H 1 0001 002H call PUT VRAM 149 hl S OR EXPANSION MODULE de 00227H iy 00014H a 002H call VRAM DISPLAY 60 SECONDS id 1 08 00 call TIMER 1 TURN OFF DISPLAY
64. L6 1 C SRNCTL UPATNCTRL e 1 000 e psw is zero nz L7 SOUND PORT a L8 UPATNCTRL UPFREQ song data area is inactive turn off CHO send out current LSN current CTRL data mask MSN point to last CTRL data sent compare CTRL has changed SAVE CTRL new CTRL data send new CTRL data look for inactive code oFFH this sets 2 flag if E OFFH data area is inactive turn off CHx send out current ATN and FRI 10 send out attenuation send out frequency 87 LOAD NEXT NOTE IDENT LOADNEX includes LOAD NEXT NOTE B B LOAD NEXT NOTE KKK KK COMMENT see Users Manual for description SFX refers to the beginning address of a special sound effect routine i Globals GLB LOAD NEXT NOTE GLB REST ENDREP ENDNOREP EFFECT TYPEO TYPE1 TYPE2 TYPE3 7 GLB MODBO DE TO DEST PASS1 Externals EXT JUKE BOX INCLUDE OSSR_EQU 0S 0 equates Defines ATN EQU 4 NLEN EQU 5 FSTEP EQU 7 ASTE EQU 8 INACTIVE EQU OFFH LOAD NEXT NOTE deactivate area save SONGNO on stack ld a 1 000 byte 0 and 03FH mask CH if any push af save SONGNO on stack ld 1 000 INACTIVE deactivate
65. N NAME x FLG 2 sup VRAM flg on See which graphics mode GR II mode 7 GO DE FIRST GEN NAM SV 2NUMGEN GAI CALC source offset 94 th EMI MID EMI BOT EMI push hl inc bc ld a bc BE i l a inc bc ld a bc lu h a pop bc pop iy pop af is point HL gt SOURCE BUFFER DE INDEX TO START OF VRAM ENTRIE TY NUMBER OF ITEMS BC OFFSET TO COLOR AF OBJ TYPE amp SUP Fill as needed top mid bit JE call call bit jr call call bit zd call EXIT ret EMI GRI ex ld 1 push pop inc ld inc ld ld push push push push 1 11 1 1 dec srl ru srl rr ST rr Sra 7 a z SEMI MID SUP GEN CLR 0 de hl 11 b 000H bc iy hl a 11 hl h h1 l a hl bc de iy a 003H PUT VRAM bc hl 1 d h hl bc hl C DFE p HL gt source buffer PTRN GNRTRS S TO READ FROM VRA SOURCE BUFFER 2 VRAM FLG UNNEEDED and bot PTRN GNRTRS amp DITTO for COLOR GNRTRS bit 7 OBJ ON top GO HNDL MID bit 6 OBJ ON mid bit 5 OBJ ON bot HL gt NUMGEN IY NUMGEN
66. OFFH INIT SOUND PAR INIT SOUNDQ dw dw dw INIT SOUND Bl ld 00002H 00001H 00002H bc INIT SOUND PAR de PARAM AREA PARAM a PARAM AREA b a hl PARAM AREA 1 initialize PTR TO LST OF SND ADDRS with value passed in HL TO LST OF SND ADDRS hl store inactive code at byte 0 of each of the n data areas B n inc inc 1 djnz hl pt HL to song 1 data area entry in LST OF SND ADDRS hl e hl pt DE to byte 0 in first song data area hl d 11 de hl pt HL to byte 0 in first song data area 00AH set DE for 10 byte increment d 000H 1 0 deactivate area hl de HL to byte 0 next area 10 bytes away Bl do this for n passed in B data areas store end of data area code 0 at 1st byte after last song data area 1 h1 000H Store end of data area code in byte 0 data area 1 set the 4 channel data area pointers to a dummy inactive data area 80 hl DUMAREA point HL to inactive byte below after the R addr DUMAR addr DUMAR addr DUMAR addr DUMAR TO S ON 0 hl PTR TO S ON 1 hl TO S ON 2 1 TO S ON 3 hl initialize SAVE CTRL ld ld ALL OFF 1 Out ld out 1 out ld ou re DUMAREA db ck cf note Will a 1 SOUND PORT a a SR2ATN OFF SOUND PORT a
67. PATTERN GENERATOR TABLE 4 COLOR TABLE START INDEX in DE DATA BUFFER in HL COUNT in IY 161 push af cp 000H JE nz ELSEZZ ld a MUX SPRITES cp 001H jr nz ELSEZZ pop af push hl ld hl LOCAL SPR TABLE ld a e sla a sla a ld e a add hl de ex de hl push iy pop bc ld sla a sla a ld hl ldir jr END IFZZ ELSEZZ pop af call SET COUNT call VRAM WRIT END IFZZ ret LE PROCEDURE INIT SPR ORDERO SPRITE COUNT BYTE INIT SPR P dw 00001H dw 00001H INIT SPR ORDERQ ld bc INIT SPR P ld de AREA call ld a PARAM AREA INIT SPR ORDER Desc Initializes the sprite display order list in RAM to default order 0 31 Input Number of sprites to order in A INIT SPR ORDER ld b a id hl SPRITE ORDER INIT SPR10 id hl a inc hl inc a cp b jr nz INIT SPR10 ret 162 PROCEDURE WR SPR NM TBLO SPRITE COUNT BYTI WR SPR P dw dw 00001H 00001H WR SPR NM TBLQ ld ld call ld WR SPR NM TBL Writes SPRITE NAME TABLE Desc bc WR SPR P de PARAM AREA PARAM a PARAM AREA to using the sprite order list Input Number of sprites to write in A WR SPR NM TBL id ix SPR
68. R3ATN OFF S OUND PORT a S RNATN OFF UND PORT a OFFH store store store p HI DDP YP at PTR TO S ON O at PTR TO S ON 1 at PTR TO S ON 2 at PTR TO S ON 3 this is only time MSN SAVE CTRL be non zero SAVE CTRL a thus ensuring PLAY SONGS will output lst real CTRL data form send form send form send form send turn off all 4 sound generators off code it out off code it out off code it out off code it out 81 for for for for tone generator 1 tone generator 2 tone generator 3 noise generator N JUKEBOX IDENT JUKEBOX includes JUK JUKE BOX pOCKCKCkCk ck kckckckckckckckckckckckckckcke ke ke ke kk COMMENT See Users Manual for description SONGNO passed in B i Globals H GLB Externals E INCLUD JUKE BOX PAR JUK JUK BOX PT IX TO SxDATA LOAD N OSSR_EQU 0S 0 E_BOX equates EXT NOTE UP CH DATA PTRS SONGNO on stack point IX to SONGNO s song data area CH if any SONGNO if any 0 0 SONGNO 7B SONGNO test if already in progress if so leave PTR thru LOAD NEXT NOT 51 1 store SONGNO in byte 0 PT IX TO SxDATA MSB SxDATA T OF SND ADDRS point HL
69. TIMER ROUTINES The users have to reserve two free RAM spaces to use timers The first RAM space is for the timer table itself the second one 18 for extra data block needed for repeating long timers The following data structures are how the timers looks like in RAM General timer data structure 3 bytes TIMER DONE REPEAT FREE EOT LONG Specific timer data structures ONE TIME SHORT TIMER DONE 0 0 0 0 5 Unsigned counter value REPEATING SHORT TIMER DONE 1 0 0 0 Unsigned current counter value Unsigned original counter value ONE TIME LONG TIMER DONE 0 0 0 1 Unsigned counter value low part LSB Unsigned counter value high part MSB REPEATING LONG TIMER DONE 1 0 0 1 Pointer to a data block for extra timer information DATA BLOCK Unsigned current counter value low part LSB Unsigned current counter value high part MSB Unsigned original counter value low part LSB Unsigned original counter value high part MSB Note The following routines have been done by Ken Lagace and Rob Jepson in March 82 41 TIME MGR ADDRESS 1FD3 INPUT None FUNCTION S Get timer table address from TIMER TABLE BASE 7303 7304 Update all timers in timer table OUTPUTS None CALLS No
70. UP ROUTINE The BOOT UP routine handles power on resets and restarts to 0 It initializes the stack and jumps to the POWER UP routine BOOT UP Kick stack ld Sp STACK jump to POWER UP jp POWER UP filler 0006 db OFFH OFFH RESTART VECTORS 4 zi The following are the 8 programmable restarts For each of the restart locations below ther is a vector in cartridge ROM To use a restart the programmer must place the address of the routine which he she wishes to access through the restart at the corresponding vector Thereafter every time that restart is executed the cartridge programmer s routine will be called RST 8H jp RST 8H RAM 66 filler 000B db RST 10H OFFH OFFH OFFH OFFH OFFH RST 10H RAM filler 0013 db RST 18H OFFH OFFH OFFH OFFH OFFH RST 18H RAM filler 001B db RST 20H OFFH OFFH OFFH OFFH OFFH RST 20H RAM filler 0023 db RST 28H OFFH OFFH OFFH OFFH OFFH RST_28H RAM filler 002B db RST 30H filler 0033 OFFH OFFH OFFH OFFH OFFH RST 30H RAM OFFH OFFH OFFH OFFH OFFH INTERRUPT VECTORING SOFTWAR Fl MASKABLE maskable interrupt occuring in the system is equivalent to a restart to 38H Thus the maskable interrupt is vectored in exactly the same way as the various restarts given above In order to use
71. WRITER _ WRITER ld a DEFER WRITE push af Save deferal flag S 100 SI QUI SS Z AN E TAIL 0 SS EAD ADDRE LOCATION id a FALSE id DEFER WRITES a WRTR WHILE id a QUEUE TAIL ld hl QUEUE HEAD cp h1 jr 2 END WHILE id hl TAIL ADDRESS 1 AED inc hl id d 1 inc hl b hl PO inc hl push de pop ix push hl call DO PUTOBJ ld a QUEUE TAIL inc a id hl QUEUE SIZE cp hl jr nz WRTR ELSE ld a 000H ld QUEUE TAIL a ld hl BUFFER id TAIL ADDRESS hl pop hl jr WRTR END IF Else WRTR ELSE ld QUEUE TAIL a pop hl id TAIL ADDRESS hl WRTR END IF jr WRTR WHILE End While WRTR END WHILE pop af id DEFER WRITES a End WRITER ret H External EXT PUTSEMI PUT MOBILE EXT DEFER WRITES EXT PARAM _ PUTOBJ PAR dw 00002H dw 00002H dw 00001H ER WRITES While QUEU FALSI E TAIL QUEUE EAD Do Write data at QUEU Get object pointer Get parameter PUTOSPRITI Process object in QUEUE Save QUEUI Incremen E TAIL to VRAM E TAIL address t QUEUE TAIL If QUEU QUI Then E TAIL
72. a pointer to the new sprite name tabl ntry being build by this routine EHE THIS SPRITEEQU IX THIS SPRITE is a pointer to the sprite object being put 110 GRAPHICS EQU 0 STATUS EQU 2 SPRITE INDEX EQU 4 Field offsets for SPRITE OBJECT records OBJECT TYPE EQU 0 FIRST GEN NAME EQU 1 PTRN POINTER EQU 2 NUMGEN EQU 4 FRAME TABLE PTR EQU 5 Field offsets for SPRITE GRAPHICS records FRAME EQU 0 X LOCATION EQU 1 Y LOACTION EQU 3 NEXT GEN EQU 5 Field offsets for SPRITE STATUS records COLOR EQU 0 SHAPE EQU T Field offsets for FRAME records EQU 0 X EQU 1 EQU 2 COLOR AND TAG EQU 3 Field offsets for SPRITE records External Procedures Ck Ck ck Sk Ck kk ck kk kk kk k E External EXT VRAM GET VRAM PUT VRAMP TABLE CODE BYTE START INDEX SLICE BYTE VAR DATA BUFFER ITEM COUNT INTEGER GET VRAMP TABLE CODE BYTE START INDEX SLICE BYTE H VAR DATA BUFFER ITEM COUNT INTEGER PUT VRAM sends a block of data to the table specified by TABLE CODE The SLICE START INDEX and ITEM COUNT are table dependant GET VRAM does the inverse operation TABLE CODE is passed in A S
73. area A header new not ld 1 ix 001H HL addr new note in ROM ld h 1 002 ld a hl header new not save header of new note in song on stack 5 and load its data CASE note type 1 b a save header new not in B test for rest bit 5 a test for rest A if psw is nzero note is rest jr z L13 CASE rest REST push bc save header on stack and 01 mask all but duration bits inc hl addr of the header of the note after this note ld ix 001H 1 store in NEXT NOTE PTR ld ix 002H h move this note s data and fill in bytes where necessary id ixtATN OF0H set stn off ld ix NLEN a NLEN 5 bit duration ld ix FSTEP 000H indicate freq not to be swept ld ix ASTEP 000H indicate atn not to be swept jp MODBO test for of song 1132 88 bit 4 test for end if psw is nzero end of song 2 114 bit 3 a test for repeat if PSW is nzero end of song jr 2 ENDNOREP CASE song repeat ENDREP pop bc B SONGNO call BOX to reload 1st note of this song ret to PROCESS DATA AREA don t save header CASE end song no repeat ENDNOREP ld a INACTIVE push af save inactive code to end song jp MODBO to load byte 0 test for special sound effect L14 and 03CH mask irrelevant bits cp 004H test for B5 B2 0001 H lf psw
74. byte update of the snd chip noise control register or any attanuation register IX is passed pointing to byte 0 of a song data area MSN register C formatted channel attenuation code i UPATNCTRL ld a ix 004H MSN A ATN LSN may be CTRL data bat 4 test for E if psw is nzero ATN is to be sent move it to LSN jr z L24 rrca swap nibbles rrca rrca rrca L24 and 00FH mask MSN or formatted register or CTRL out SOUND PORT a output ATN or CTRL data ret e koe ke kc kc ke ke kk kk kkk ke ke kc ke ko koe e ke ke ke ke e COMMENT Perform double byte update of a sound chip frequency register IX is passed pointing to byte0 of a song data area MSN register D formatted channel frequency code i UPFREQ ld 1X FREQ F2 F4 F5 F7 F9 and 00FH 0 0 0 0 F6 F7 F8 F9 OT d FORMATTED REG FO F7 F8 F9 out SOUND PORT a output 15 freq byte ld a 1X FREQ F2 F4 F5 FO F7 F8 FY and OFOH F2 4 F5 0 0 0 0 1 save D id a 1 LSN 0 0 FO F1 76 and 00 0 0 0 0 0 0 FO Fl or d F2 4 F5 0 0 FO FL rrca swap nibbles rrca rrca rrca 0 0 FO Fl F2 F4 F5 out SOUND PORT a output 2nd most significant freq byte ret P DECLSN 2
75. db 0 OEOH OEOH 0 0 db 01 07 079H 078H 07 080H OEOH OEOH 000 080 db OF3H OFBH OFBH OFBH OFF db OCO db OF3H OFFH OFFH 07 db 000 db OFOH OFOH OFFH OFFH OFFH OFF db 000H OOOH OCO db 03FH 01 01 01 OOEH 00 150 CX CY CO OGO CO CX CX CX fr 09 Cx OO C CO OOO OO CO OO 088H 08DH 08AH 08FH db db db db db db ASC TABLE db db db SPACE db db db db db db db db db db db db db db db db NUMBER TBL db db db db db db db db db db db db db db db db db ASCII TBL db db db db db db db db db db db db db db db db db 080H 000 000H 000 OFOH OFO OFOH OFO 01 001 079H 07 OEOH OEO OEOH OEO OFFH OF7H OF7H OF7 OCOH OCO OCOH OCO 07EH 081H OBDH 1 01 004 004 004 044H O6CH 054 054 000H 000 000H 000 020H 020 020H 020 050H 050 050H
76. hl Compare with 0 cp 000H jp z CONTINUE X BYTE STATUS X LOCATION 32 dec hl HL X LOCATION id C hl inc hl ld b hl ld h1 00020H 2292 hl bc ld 1 1 iy X a COLOR AND TAG GRAPHICS FRAM TABLE STATUS FRAME COLOR Or 80h ld l ix GRAPHICS ld h ixX GRAPHICS 1 ld de FRAME TABLE PTR add hl de HL FRAME TABLE PTR ex de hl 1 ld l a inc de 1 ld h a HL FRAME TABLE PTR push hl ld l L1x STATUS 1 h 5 05 1 1 de FRAME add hl de HL FRAME 113 ld a hl Calculate offset of sla a COLOR entry ld bc 00000H id hl add hl bc HL COLOR id a hl Or in 80h 080H ld iy COLOR AND TAG a jr PUT Y AND NAME Else Continue from here CONTINUE X BYTE STATUS X LOCATION ld l i4x STATUS ld h 3x STATUS 1 ld de X LOCATION add hl de HL X LOCATION ld a hl id iy X a COLOR AND TAG GRAPHICS FRAME TABLE STATUS FRAME COLOR ld l ix GRAPHICS id h ixX GRAPHICS 1 ld de FRAME TABLE PTR add hl de HL FRAME TABLE PTR ex de hl ld a de ld l a inc de 1 id h a HL FRAME TABLE PTR push hl i ld l ix STATUS ld h 3x STATUS 1 ld de FRAME add hl de HL FRAME ld a hl Calculte offse
77. hl pop de add hl bc ex de hl call MAGNIFY ex af af push af ex af af pop af exx push hl exx pop de ld hl WORK BUFFER id bc 00008H add hl bc ld iy 00004H call PUT VRAM call COLOR TEST 001H jr nz END IF 4 GRAPHICS call GET COLOR hl WORK BUFFER id bc 00008H push hl pop de add hl bc ex de hl call QUADRUPLE ld a 004H exx push hl exx pop de 1 hl WORK BUFFER id bc 00008H add hl bc ld iy 00004H call END IF 4 GRAPHICS exx inc hl inc hl inc hl inc hl jp RETURN HERE COLOR TEST Desc Tests whether pattern generators are being manipulated and wheter the graphics mode is 2 If so the above routines need to deal with the color generators that correspond to the pattern generators they are operating on Input no Output 1 if true 0 if not COLOR TEST ex af af 171 push ex pop jr 1 bit jr 1 ret EXIT FALSE 1 ret PUT TABLE af af af af 003H nz EXIT FALSI hl VDP MODE WORD 1 hl 1 z EXIT FALSI a 001H 000H Desc Puts the contents of WORK BUFFER 8 at the given destination PUT TABLE ex af af push af ex af af pop af exx push hl exx pop de ld hl WORK BUFFER id bc 00008H add El bc ld iy 00001H call ret GET C
78. inc de dec b ld a b cp 000H jr nz RPT1 UNTIL B EQ 0 id iy WORK BUFFER jr ENDO4 ld b 000H push bc E ld a b x add a b add a b id h1 00000H id 00018H E ld a b dec a jp m AD EXIT add hl de jr AD LP Offset from start of ptrn and color buffers T id iy WORK BUFFER ld a add a b IF A LT 24 cp 018H jr nc END15 srl a H srl a H srl a ld d a ld e c 2 push de E ld bc BK PTN add hl bc ld bc WORK BUFFER hl bc push hl ld iy 00003H id a 003H call PUT VRAM pop hl 1 de BK CLR BK PTN hl de pop de 1 iy 00003H ld a 004H call PUT pop bc Restore counter and index 125 inc id cp jr IF B ENDO4 b a b 003H nz RPT2 EQ 3 Repeat 3 times Restore OLD SCREEN if it s Y PAT POS and X POS differs from the Y POS and X_ 14 H B Or sbc jr ld id add ld ld 1 11 END17 END16 iy WORK BUFFER b 4y XP OS NE 80H z END16 OS iy XP_ BK BK hl bc PSW IS NZERO z END17 hl WORK BUFFER de YP_OS 1 hl de iy XP OS d iy YP OS 00303 PUT FRAM Fl Place object on screen ld ld ld add ld ld ld call ret Regs H and generators with A H and L
79. is to be saved Get high byte of OLD SCREEN address Test bit 15 of OLD SCREEN address Save regs Then OLD SCREEN in CPU RAM 103 EQUAL TO inc JE M XY add 310772 djnz push pop ex pop inc inc inc inc call SKIP OLD pop END IF 1 Q BHU asasanminda p p m 5 Q H a push call hl WORK BUFF ix 005H x 004H ae i de cl bc 00004H VRAM READ nl a 11 080H nz GET OLD de SKIP OLD hl hl hl e hl 000H hl de hl 1 L0772 VRAM READ b hl hl PUT FRAME HL T OLD SCRE OLD SCRE Save 2 copies Save OLD SCRE Read 4 bytes HL EXTI ENT EXTI ENT Multiply X EXTI Ij EN address OLD SCREEN in VRAM Get address of fr buffer spac EN address free buffer addr addr X Y PAT POSs X Y EXTENTs Free buffer addr of OLD SCREEN n ENT Y EXTENT in HL Number of bytes to read Free buff addr 4 OLD SCRE EN addr Read saved names for background HL free buffer addr X PAT POS Then there is an OLD SCREEN X PAT POS Y PAT POS X Y EXTI ENT EXTI ENT 5 HL points to 156 name in
80. kk Sk kk Ck kk ck kk Sk Sk Ck CALC OFFSET push hl D IS MINUS EXTEND SIGN bit 7 d nee z ELSE 11 ld h OFFH jr END IF 11 ELSE 11 id h 000H END IF 11 ld 1 4 Offset 32 Y PAT POS X PAT POS add hl hl HL 2 Y PAT POS add hl hl 2 4 hl hl 2 M add hl hl 16 N add hl nl 32 IF E IS MINUS Extend sign bit 7 jr z ELSE 12 ld OFFH jr END IF 12 ELSE 12 000 END IF 12 add 1 4 HL 32 Y POS X POS ex de hl DE 32 Y PAT POS X POS pop hl ret gt Ck ckckckckockckck ck ckck ck k ck ck k kk EXTERNALS Ck ck ckckck ck ck ckck ck ck ck ck ck ck ck kk EXT GET VRAM EXT PUT VRAM EXT VRAM READ EXT VRAM WRIT EXT WORK BUFF 109 PUT SPRITE RTN ke ke kk KKK e ke he ke e ke ke ke ke ke e ke ke kc he he ke e ke ke Sk e ke ke e he ke ke e ke ke e ke DESCRIPTION This module contains code for the PUTISPRITE and PUTOSPRITE 2 routines These routines turn out to be essentially the same code with two slihntly different entry points INPUT IX Address of the sprite object The format for sprite objects is SPRITE OBJECT RECORD GRAPHICS SPRITE GRAPHICS STATUS SPRITE STATUS SPRITE INDEX BYTE SPRITE NAME TABLE index of this sprite END SPRITE OBJECT
81. list Save object poin Restore OLD SCRE Cer EN to display 104 END IF SVE SV2 M XY2 add M 2 1 djnz push exx pop pop call ix hl de bc bc de hl h 1 005 1 ix 004H a 070H h c END IF 3 H LT 70H hl WORK hl e hl 1 hl c hl hl b hl ix GET BKGRND ix hl de bc ix PUT FRAME ix d 1 005 a 070H d z END IF 4 c END IF 4 D LT 70H e 1 004 hl WORK BUFF hl hl hl e 51 000H hl b hl de hl 2 1 hl hl XY2 hl bc hl VRAM WRITE Restore object pointer HL Addr of 15 name in frame DE Y X PAT POSs BC Y X 5 HL OLD SCREEN addr The OLD SCREEN now in free buffer Therefore move background to buffer REEN 0 X PAT POS REI SC Y PAT POS REI X EXTENT SC REEN 3 Y EXTENT HL Addr to store names Save object pointer Restore object pointer Where names are in CPU RAM Where to move then in VRAM How many to move Save object pointer TABLI NAME Ij Restore object pointer See if saved background to be moved to VRAM T DE Use Where next OL OLD SCREEN addr reg for calculation D SCREEN data is
82. lookup id Save in controller memory 2kbd JE EXIT KBD 571 1 Get current data cp b old new jr Zz EXIT No change in state id OLD e Else save current data Set state 0 ld 1y KBD STATE a KBD EXIT pop hl pop de pop bc ret Fire debounce routine Input A Raw data 7 IX Controller memory pointer IY Debounce status buffer FIRE DBNCE push bc push de 144 FIRE MASK e a b iy FIR a 1 000H nz FIRE 571 OLD STATE 1y FIRE_ STATI ix FIRE e FIRE EXIT debounce routine Input A Raw data and 1 1 1 jr FIRE STO ld jr ld jr FIRE REG ld ld id jr FIRE 571 id jr ld 1 FIRE EXIT pop pop Joystick IX LY JOY_DBNCE push push and ld id id jr JOY STO id jr id jr JOY REG 1 1 ld jr JOY 511 ld jr id bc de JOY MASK e a iy JOY OLD 1 STATI 000H nz JOY 5 1 Fl iy JOY OLD e a b z JOY REG JOY EXIT a 001H 1 STAT 1 90 JOY EXIT Fl JOY EXIT iy JOY OLD e 7 N OM Mask out valid data and save it Get old data and current status If state lt gt 0 T
83. number of names poA name tabl 2 s compl Add displ Restore DE X PAT POS Now adjust starting points in frame list and 32 Get count into IY Le Save X and Y extent Frame bleeding on from left Calculate amount of frame on screen ENT X PAT POS If number of names 32 Liment of X PAT POS lacement to frame pointer Add displ ENT 1 time 107 Is X PAT POS X_ lacement to nam EXTI tabl pointer ENT 31 S Get this number into IY Both ends of frame within pattern plane RPT 1 4 Get Y PAT POS add a e Add Y IF A IS PLUS bit 7 a jr nz END IF 10 A IF A LE 23 Is 0 lt Y POS Y lt 23 018H jr nc END IF 10 push bc push de exx push bc push de push hl push iy ld a 002H Code for pattern name table added 4 20 call VRAM pop iy pop hl pop de pop bc END IF 10 exx push bc 1 b 000H Increment pointer into frame by X EXTENT add hl bc ex de hl id bc 00020H Increment offset by 32 add hi be ex de hl pop bc exx inc e UNTIL E EQ B Until Y Y EXTENT ld a e cp b jr nz RPT 1 ret ek sk k k kk k k GET BKGRND KKK KK KK KKK ck kk kk ck kk kk Ck KK kk KK ck ck kc kk kk Description This routine gets the names from the name table which Input GET BKGRND call push l
84. the Europe America byte 0069h to determine the current line frequency 60 3Ch for America based units and 50 32h for European based units Graphics Tables There are two 2 graphics tables in the OS available to the user The pointers to these tables are defined in the locations ASCII TABLE 006Ah and NUMBER TABLE 006Ch It s IMPORTANT to get the pointers to the ASCII and number generator tables by using these locations The ASCII table contains pattern generators for all 26 upper and pseudo lower half size upper case letters plus eleven special characters in 5x7 dot matrix form The number table contains pattern generators for the numbers from 0 to 9 plus seven special characters Cartridge ROM At the beginning of the Cartridge ROM locations are reserved for testing cartridge presence 8000h AAh 55h to display OS logo screen 55h AAh to not display OS logo screen plus a number of pointers which points to tables buffers and start of the game see the Appendix for details After the pointers it s the programmable restart and interrupt vectors And after the vectors at GAME NAME location 8024h it s normally the space up to 60 bytes reserved to show game informations on the logo screen Of course we know now that the space for the game informations on the logo screen could be bigger than 60 bytes however this size of 60 bytes is really enough RAM Areas Eleven 11 bytes are reserved for OS sound data starting at 7020
85. to 1st name H H I I Move colors to color generator table Get name Point to next name Divide by 8 DE Offset into color gen table Save counter Test whether this pattern position is on the screen or not i e is YP BK B 9 3 between 0 and 23 and is XP BAK B 9 3 mod 3 between 0 and 31 X POS B 9 3 mod 3 Y POS B 9 3 Is this position on screen 7 And pointers Code for color generator table Number of items to send 124 NOTOS PM13 RPT2 AD LP EXI END15 5 04 Restore pointers And counter Increment pointers Decrement counter Restore buffer addr Save counter and index Add 3xcounter to index where next gens to be moved Calculate offsets from start of pattern and color generator tables Index to table location for next 3 gens Get Y PAT POS to see which 3rd of tables to use each group of 3 in next pattern plane row A must countain valid Y PAT POS 0 23 This number 8 indicates which 1 3 of table to use DE Index into pattern and color tables Save index Form pointer to generators in HL Get buffer base addr Save this pointer Number of elements to move Pattern generator table code Get pointer back n buffers Offset betw HL points to start of next 3 color generators Get index into gen tables pop hl bc hl E
86. 0 END21 END18 PM15 bit IF z END19 1 000 a h a z END20 1 008 1 z END21 1 010 7 43y FLAGS PSW IS ZERO Yes then replace background with object Same for middle Same for right hand byte Find out which graphics mode used Then mode 2 mode 1 colors done after combined loop END24 END25 END26 END22 jr push ret z END22 ix bc BK CLR BK PTN ix bc b iy COLR 1 iy FLAGS PSW IS ZERO nz ELSE23 00 END23 z END25 a 1x 008H G b 1 008 pls a a z END26 a 1 010 b 1 010 ix Save background pointer Change IX to point to color generators Get object color 0 background or transparent 2 Then use background 1 0 Mask for 1 0 of background Mask replace 1 0 with transparent Get 156 object s pattern byte Are there any 1 bits Get background color gen Mask out colorl Add object colorl Update color generator Same for middle byte Same for right hand byte Restore background pointer 127 PUT COMPLEX IDENT PUTCOMP ZOP IF1 INSERT B SPZ80 ASM COMMENT PUT COMPLI 4 15 82 10 40 00 EX
87. 0 51270 See 169 ENLARGE jp ENLRG 61 73 See page 169 CONTROLLER SCAN jp CONT SCAN 61 76 See page 140 DECODER DECODER _ S1F79 See page 141 GAME OPT jp GAME S1F7C See page 155 LOAD ASCII LOAD ASCII 1 7 See page 153 FILL VRAM jp FILL 1F82 See page 152 MODE 1 jp MODE 1 S1F85 See page 153 UPDATE SPINNER jp UPDATE SPINNER _ 51 88 See page 141 INIT TABLEP INIT TABLEQ S1F8B See page 158 GET VRAMP jp GET VRAMQ 1 See page 159 PUT VRAMP PUT VRAMQ S1F91 See page 161 INIT SPR ORDERP jp INIT SPR ORDERQ S1F94 See page 162 WR SPR NM TBLP jp WR SPR NM S1F97 See page 163 INIT TIMERP jp INIT TIMERQ 1 9 See page 133 FREE SIGNALP jp FREE SIGNALO S1F9D See page 133 REQUEST SIGNALP jp REQUEST SIGNALO 5 See page 135 177 TEST SIGNALP jp TEST SIGNALQ WRITE REGISTERP jp REG WRITEQ WRITE VRAMP jp WRITE VRAMQ READ VRAMP jp READ VRAMQ INIT WRITERP jp INIT QUEUEQ SOUND INITP jp INIT SOUNDO PLAY ITP jp JUKE BOXQ INIT TABLE jp INIT TABLE GET VRAM jp VRAM PUT VRAM jp PUT INIT SPR ORDER jp INIT SPR ORDER WR SPR NM TBL ip WR SPR NM TBL INIT TIMER jp INIT TIMER FREE SIGNAL jp FREE SIGNAL REQUEST SIGNAL jp REQUEST SIGNAL TEST SIGNAL El d
88. 00H n db 000H 000H OF8H 088H 088H 088H OF8H 000H o db 000H 000H OFOH 088H OFOH 080H 080H 000H p db 000H 000H OF8H 088H 0A8H 090H OEOH 000H q db 000H 000H OF8H 088H OF8H 090H 000H db 000H 000H 078H 080H 070H 008H OFOH 000H s db 000H 000H OF8H 020H 020H 020H 020H 000H t db 000H 000H 088H 088H 088H 088H 070H 000H u db OOOH OOOH 088H 088H 090H OAOH 040H OOOH v db 000H 000H 088H 088H 0A8H OD8H 088H 000H w db 000H 000H 088H 060H 020H 060H 088H 000H x db 000H 000H 088H 050H 020H 020H 020H 000H y db 000H 000H OF8H 010H 020H 040H OF8H 000H z db 038H 040H 020H OCOH 020H 040H 038H OOOH db 040H 020H 010H 008H 010H 020H 040H OOOH db OEOH 010H 020H 018H 020H 010H OOOH db 040H 0A8H 010H 000H 000H 000H 000H 000H db 050H 0A8H 050H 0A8H 050H 0A8H OOOH deleted OBJ TABLE db 001 002H 00 00 008 009H 012 013 003 004 00 00 005 014 000 000 db 005H 000H 010 011 00AH 00 015 016 db 006H 007H 010 011 005H 014H 000 000 db 001 002H 00 00 003H 004 00 OOFH 003H 004H 00 00 00 017 018 OFFH END OF TABLE INDICATOR Desc Writes DE number of time a byte value in vram at HL address INPUT HL INDEX IN VRAM A BYTE TO COPY DE COUNT AFFECT
89. 2 CONTROLLER MAP FE6E FE6F 7020 7021 TO LST OF SND ADDRS FE70 FE71 7024 7025 PTR TO S ON 1 NOT SURE FE72 FE73 7026 7027 PTR_TO_S_ON_2 NOT SURE FE74 FE75 7028 7029 PTR_TO_S_ON_3 NOT SURE FE76 FE77 7022 7023 TO S 0 NOT SURE FE78 702A SAVE CTRL CONTROLLER MAP in the cartridge header points to the controller memory map used by the bios routine POLLER The joystick data are decoded into 12 bytes player 1 enable player 2 enable p1 fire pl joy pl spinner pl arm pl keypad p2 fire p2 joy p2 spinner p2 arm p2 keypad 185 280 I O PORTS ASSIGNMENTS Extracted from Technical Reference Manual Note Ports 000H through 07FH are reserved for the ADAM computer They are mentionned here for those who wants to elaborate special Coleco games with extra options when plugged in the ADAM Video Display Processor Data port Register port Sound Generator Data port OFFH write only Game Controller Strobe Set port 080H write only Strobe Reset port write only Controller 1 port OFCH read only Controller 2 port OFFH read only MODEM Data port 05 Control port 05 Auto Dialer Expansion connector 2 Data port 04FH Memory Map Control port 07 Network reset Performed by setting and resetting bit 0 EOS enable Performed by setting bit 1 EOS disable Performed by resetting bit 1
90. 2END EQU 090H CH3END EQU ODOH CHOREP EQU 018H EQU 058H CH2REP EQU 098H CH3REP EQU OD8H Channel numbers B7 B6 CHO EQU 000H CH1 EQU 040H CH2 EQU 080H CH3 EQU OCOH 73 FREQ SWEEP RTN INCL 6010 Ext H Def FSTEP FPSV NLEN IDENT FREOSW I includes FREQ SWEE UDE OSSR_EQU 0S 0 equates bals GLB FREQ SWEEP ernals GLB DECLSN DECMSN MSNTOLSN ADD816 ines EQU 007H EQU 006H EQU 005H FRI EO SWEEP ko ko ke ke ke kc ke ko koe e ko ke ke ke COMMENT See User s Manual for description RETS Z SET if note over RETs Z RESET if sweep in progress or note not over i FREQ SWEEP if freq not swept dec NLEN and RET setting Z flag ld 1X FSTEP check for no sweep code cp 000H Z flag if FSTEP 0 TE psw is zero note not to be swept jr nz L20 1 ix NLEN dec NLEN and dec a SET Z flag if 0 ret leave if note over with Z flag SET ld ixtNLEN a store decremented NLEN ret RET with Z flag RESET note not over E sweep going so decrement FPSV L20 push ix point HL to FPSV pop hl id e FPSV ld d 000H add hl de call DECLSN decrement FPSV TE p
91. 88H 070H 000H S db OF8H 020H 020H 020H 020H 020H 020H 000H T db 088H 088H 088H 088H 088H 088H 070H 000H U db 088H 088H 088H 088H 088H 050H 020H 000H V db 088H 088H 088H 0A8H 0A8H OD8H 088H 000H W db 088H 088H 050H 020H 050H 088H 088H 000H X db 088H 088H 050H 020H 020H 020H 020H 0008 Y db OF8H 008H 010H 020H 040H 080H OF8H 000H Z db OF8H OCOH OF8H 000H db OOOH 080H 040H 020H 010H 008H OOOH OOOH db OF8H 018H 018H 018H 018H 018H OF8H OOOH 1 db 000H 000H 020H 050H 088H 000H 000H 000H db 000H 000H 000H 000H 000H 000H 000H OF8H _ db 040H 020H 010H OOOH OOOH OOOH OOOH OOOH db OOOH OOOH 070H 088H OF8H 088H 088H OOOH db OOOH OOOH OFOH 048H 070H 048H OFOH OOOH b db 000H 000H 078H 080H 080H 080H 078H 000H c db 000H 000H OFOH 048H 048H 048H OFOH 000H d db 000H 000H OFOH 080H OEOH 080H OFOH 000H e db 000H 000H OFOH 080H OEOH 080H 080H 000H f db 000H 000H 078H 080H 088H 070H 0008 db 000H 000H 088H 088H OF8H 088H 088H 000H h db 000H 000H OF8H 020H 020H 020H OF8H 000H i db OOOH OOOH 070H 020H 020H OAOH OEOH OOOH 3 db 000H 000H 090H 0AOH 0 0 090H 000H k db 000H 000H 080H 080H 080H 080H OF8H 000H 1 db OOOH OOOH 088H OD8H 0A8H 088H 088H OOOH m db 000H 000H 088H 0 8 0A8H 098H 088H 0
92. 9 pattern FREO SWEEP Frequency sweep 012F ATN SWEEP Attenuation sweep 0190 DECLSN Decrement low nibble in UTILITY 019 DECMSN Decrement high nibble in UTILITY 01A6 MSNTOLSN Copy high nibble to low nibble in UTILITY 01 1 ADD816 Add signed 8bit value A to 16015 HL 0105 EFFECT Called by a special sound effect function when done 02 EFXOVER in PROCESS DATA AREA to get next note 07 8 PX TO PTRN POS Pixel to pattern plane position 080B PUT FRAME Copy a block of names to VRA 0898 GET BKGRND Copy a block of names from VRAM to RAM 08 0 CALC OFFSET Returns DE offset for the coordinates E D 1D43 CTRL PORT PTR in READ VRAM equal I O port 1D47 DATA PORT PTR in READ VRAM equal I O port BE IDEC ENLRG It s the local name of the ENLARGE routine 73B9 STACK Stack pointer address 7363 VDP MODE WORD Copy of the first two VDP registers 1365 VDP STATUS BYTE Contents of default NMI handler 73C6 DEFER WRITES Boolean flag to defer writes to VRAM 73C7 MUS SPRITES Boolean flag to sprite multiplexing 73C9 RAND NUM Pointer to pseudo random number value 8000 CARTRIDGE Cartridge starting address 8002 LOCAL SPR TABLE Pointer to sprite name table 8004 SPRITE ORDER Pointer to sprite order table 8006 WORK BUFFER Pointer to temporary storage in RAM 8008 CONTROLLER MAP Pointer to controller memory map 800A START GAME Pointer to game start code 800C RST Reset 8 soft vector 800F RST 10H RAM Reset 10 s
93. AL RITE VRAM EAD VRAM 0664 0679 11 1 0213 0251 027 04 0608 003B LH G P I W I T T T W R W R 1 NIT WRITER RITER POLLI IE R SOUND INIT PLAY IT SOUND MAN ACTIVATE PUTOBJ Z RAND GLOBAL OS 7 SYMBOLS SYMBOLS IN ALPHABETIC ORDER ADDRESS NAME DESCRIPTION 01 1 ADD816 Add signed 8bit value A to 16bit HL 0069 AMERICA 60 5 50 PAL 006A ASCII TABLE Pointer to uppercase ASCII pattern 012F ATN SWEEP Attenuation sweep 08 0 CALC OFFSET Returns DE offset for the coordinates E D 8000 CARTRIDGE Cartridge starting address 8008 CONTROLLER MAP Pointer to controller memory map 1D43 CTRL PORT PTR in READ equal I O port BF 1D47 DATA PORT PTR in READ VRAM equal port BE 0190 DECLSN Decrement low nibble in UTILITY 019B DECMSN Decrement high nibble in UTILITY 73C6 DEFER WRITES Boolean flag to defer writes to VRAM 02 EFXOVER in PROCESS DATA AREA to get next note 1D6C ENLRG It s the local name of the ENLARGE routine FREO SWEEP Frequency sweep 8024 GAME NAME String of ASCII characters 0898 GET BKGRND Copy a block of names from VRAM to RAM 801
94. CC 0 HEAD ADDRESS 73CD 73CE HL ADDRESS 73CF 73D0 HL OUTPUTS None CALLS None CALLED BY Under user program control NOTES Only the Accumulator is affected 28 WRITER ADDRESS 1FE8 INPUT None FUNCTION S Temporary reset defered write flag and write data at queue to VRAM OUTPUTS None CALLS DO PUTOBJ CALLED BY Under user program control NOTES Destroys all 29 PUTOBJ ADDRESS IFFA DESCRIPTION According to flag DEFER WRITES 73 6 this function updates the object specifications position x y pattern color of object IX on screen or puts the object in the queue for updating later INPUT IX Object data pointer B Object parameter selector for methods of combining object generators with background generators for mobile objects only FUNCTION S Check if DEFER WRITES flag 73C6 is true If true set up for defered write by calling SET UP WRITE If not process object by calling DO PUTOBJ OUTPUTS None CALLS SET UP WRITE DO PUTOBJ CALLED BY Under user program control NOTES Assume this routine destroys all registers 30 DO PUTOBJ INPUT IX Object data pointer FUNCTION S Get object graphics address and object type Call the appropriate put object routine based on object type OUTPUTS None CALLS PUTSEMI PUTOSPRITE PUTISPRITE PUT MOBILE PUTCOMPLEX CALLED BY WRITER PUTOBJ NOTES Assume this routine destroys all registers
95. CF CALL ACTIVAT GI Signal MV to VRAM OR s LD HL OBJ n OBJ to activate OR A Don t MV to VRAM CALL ACTIVATE External i EXT PUT VRAM VRAM WRITE VDP MODE WORD EXT WORK BUFFER Global R GLB ACTIVATEQ ACTIVATE Register usage Following will be changed by activate additional may be changed by called SUBR i PROC ACTIVATEQ is the Pascal entry point to ACTIVATI EXT PARAM AF HL DE BC IY EDURE ACTIVATEO VAR OBJ OBJECT MOVE BOOLEAN Lu The Pascal parameter passing procedure e PRM DATA DEFS 3 Moved to OS This is the common parameter passing area ACTIVATE P 92 dw 00002H dw OFFFEH dw 00001H 1 1 de PARAM AREA call PARAM _ 1 hl PARAM AREA id e h1 inc hl ld d 1 ex de hl ld a PARAM AREA 2 cp 000H jr z NTZZZ _ scf jr TZZZ NTZZZ Or a 1222 ACTIVATE SUP pointers etc common to all subcases A HL gt OBJ DEF CPU ROM FLG SUP VRAM FLG 1 1 gt GEN CPU ROM inc hl id d 1 inc hl id C hl gt CPU RAM inc hl id b h1 inc hl ld 000H ZERO FRAME ld bc a ld a de GET OBJ TYPE push af SV OBJ TYPE amp FLG and 00 GET NUM jp
96. COLECOVISION CODING GUIDE WITH THE ABSOLUTE COLECO BIOS LISTING PRELIMINARY RELEASE CONFIDENTIAL DOCUMENT DO NOT COPY Document written by Daniel Bienvenu Last modification date 28 07 2005 ACKNOWLEDGEMENTS From Technical Reference Manual Note The following text was written in every official Coleco documents Coleco makes no representations or warranties whatsoever including without limitation any implied warranties of merchantability and fitness for a particular purpose in connection with the materials contained herein and sush materials are disclosed as is Coleco shall have no liability for any losses caused to recipients of these materials by reason of any changes or modifications made by Coleco in these materials after their disclousure herein in addition Coleco shall have no liability for any consequential special indiret or incidental damages or losses whatsoever including loss of profits in connection with the use of the materials disclosed herein 1984 Coleco Industries Inc rights reserved ADAM is trademark of Coleco Industries Inc ColecoVision is a registered trademark of Coleco Industries Inc Please note that a lot of time and effort has been put into this documentation If you intend to use it for commercial purpose please ask for permission first PREFACE This document is a source of technical information for software designers This preliminary release includes th
97. E IRQ INT VECT Software interrupt vector RST 38H 0105 EAVE EFFECT Called by a special sound effect function when done 8002 TABLE Pointer to sprite name table 01A6 MSNTOLSN Copy high nibble to low nibble in UTILITY 73 7 MUS SPRITES Boolean flag to sprite multiplexing 8021 NMI INT VECT NMI soft vector 006 NUMBER TABLE Pointer to numbers 0 9 pattern 080B PUT FRAME Copy a block of names to VRAM 07 8 PX TO PTRN POS Pixel to pattern plane position 73C9 RAND NUM Pointer to pseudo random number value 800F RST 10H RA Reset 10 soft vector 8012 RST 18H RA Reset 18 soft vector 8015 RST 20H RA Reset 20 soft vector 8018 RST 28H RA Reset 28 soft vector 801B RST 30H RAM Reset 30 soft vector 800C RST Reset 8 soft vector 8004 SPRITE ORDER Pointer to sprite order table 73B9 STACK Stack pointer address 800A START GAME Pointer to game start code 7363 VDP MODE WORD Copy of the first two VDP registers 73C5 VDP STATUS BYTE Contents of default NMI handler 8006 WORK BUFFER Pointer to temporary storage in RAM 181 SYMBOLS ORDERED BY ADDRESSES ADDRESS NAME DESCRIPTION 0069 AMERICA 60 NTSC 50 PAL 006A ASCII TABLE Pointer to uppercase ASCII pattern 006C NUMBER TABLE Pointer to numbers 0
98. E VRAM READ VRAM LB INIT WRITER LB WRITER LB WRITE REGISTERP PASCAL CALLS LB WRITE VRAMP READ VRAMP LB INIT WRITERP LB POLLER CONTROLLER ROUTINES LB UPDATE SPINNER LB CONTROLLER SCAN iB DECODER LB SOUND_INIT SOUND ROUTINES LB TURN OFF SOUND PLAY IT LB SOUND MAN PLAY SONGS LB SOUND INITP PASCAL CALLS iB PLAY ITP LB INIT TIMER TIME MGMT ROUTINES LB FREE SIGNAL iB REQUEST SIGNAL TEST SIGNAL LB TIME MGR LB INIT TIMERP PASCAL CALLS LB FREE SIGNALP iB REQUEST SIGNALP TEST SIGNALP LB STACK MISC GLOBALS LB VDP STATUS BYTE LB VDP MODE WORD LB AMERICA LB MUX SPRITES DEFER WRITES LB RAND GEN Can be called from PASCAL or ASM language LB PUTOBJ GRAPHICS ROUTINES LB ACTIVATE REFLECT VERTICAL REFLECT HORIZONTAL LB ROTATE 90 ENLARGE LB PUTOBJP PASCAL CALLS LB ACTIVATEP LB GAME OPT GAME OPTIONS DISPLAY LB LOAD ASCII LOADS ASCII CHARACTER GENERATORS LB FILL VRAM FILLS DESIGNATED AREA OF VRAM WITH VALUE LB MODE 1 SETS UP A DEFAULT GRAPHICS MODE 1 LB ASCII TABLE POINTER TO TABLE OF ASCII GENERATORS LB NUMBER TABLE POINTER TO TABLE OF 0 9 PATTERN GENERATORS 64 P CARTRIDG ROM DATA AR F CARTRIDG feat EQU 08000H This is the memory location tested to see if a cartridge is plugged If it contains the pattern AA55H the OS assumes that a game cartridge is present
99. END10 9 djnz bc hl de bc 00008H READ VRAM bc 00008H hl hl bc de hl hl hl bc bc END10 de hl bc bc 00008H bc de hl de de DLP4 Combine object pattern Save buffer address Save generator address Number bytes to move Increment pointers by 8 Gen addr Gen addr 8 Bug addr Buf addr 8 Pattern in CPU RAM generators with background 11 1 WORK BUFFER ld de WORK BUFFER 1 hl BK hl de P ld C iy YDISP BC ld b 000H Displa add to be overlayed push hl pop ix 1 hl OBJ hl de M gen push hl ld af af COMBINE LOOP pop hl ld d 1 inc hl push hl ld bc 0000FH add hl bc 1 1 de hl A ld b iy XDISP SHFLP dec b jp m SHFEX add hl hl rla jr SHFLP DE Buffer base addr_ HL points to start of background generators cement of object below pattern generators HL points to lst row in background IX pointer to row in pattern buffer HL points to 1st byte in object s pattern Use A as loop counter Point to object pattern byte Get pattern byt Point to adjacent pattern byte HL has 16 bit row of object s pattern Shift left pattern by this amount Clear A 122 SHFEX ld e a call PAT COL ld a iy YDISP
100. ES HL is restored 33 PUT FRAME DESCRIPTION Puts a box of names characters on screen It prevents bleeding outside visible screen INPUT HL address of list of names characters that compose the frame POS POS EXTENT EXTENT FUNCTION S The names which constitute a frame are moved to the name table in VRAM The upper left hand corner of the frame is positioned at X POS PAT POS OUTPUTS None CALLS CALC OFFSET PUT VRAM CALLED BY PUTSEMI PUT MOBILE NOTES 34 GET BKGRND DESCRIPTION Gets a box of names characters from screen INPUT HL location in CPU RAM to copy names from POS POS EXTENT EXTENT FUNCTION S Gets the names from name table which constitute the background in which an object 15 to be moved at X PAT POS Y PAT POS OUTPUTS None CALLS CALC OFFSET GET VRAM CALLED BY PUTSEMI PUT MOBILE NOTES 35 CALC OFFSET INPUT D Y PAT POS E X POS FUNCTION S This routine calculate the proper offset into the name table for the pattern position given by X POS Y POS The formula used is offset 32 Y POS X POS OUTPUTS DE offset CALLS None CALLED BY PUT FRAME GET BKGRND NOTES DE is affected 36 PUTOSPRITE 37 PUT1SPRITE 38 PUT MOBILE 39 PUTCOMPLEX 40
101. GLB REG WRITEQ VRAM WRITEQ VRAD The AF BC NOTE For each point w of the rou hich allows DE and HL register pairs are all affected This procedure is not re entrant tines listed abov the routine to be called using the standard pascal there is an additional entry 64000 parameter passing protocol and passing the parameters through a common data area into the registers these routines in t driven environment name of a given rou is NameQ for the ac jump table in OS ROM tine is Name tual routin It should not be noted that use of his fashion any cause problems in an interrupt They should therefor be used with care the name of the additional entry point If the named NameP when called through the entry points destroy all registers ck ck kk ck ck ck kk kk kk ck kk ck kk ck kk kk KKK ko ck ko Sk ko Sk Sk A kx kv ko ko Ck ck Kok ck Ck ck ck ck Ck ck kk Sk kk kk ok Kk ko ko ko ko ok DICTIONARY ck Ck Ck ck Sk Ck kk ck kk Sk kk kk ko ko ko ko ko kock ko Ck ck ckckckckck ckckckck ck kckck kc ck ck kk PROCE REA R DURI ES AND FU D KK KK KK KK KK KK KK KK KK KK KK KK KK KK KK KK KK KK KK IK IK IK IK IK IK IK IK CTIONS
102. INPUT None FUNCTION S Turn off all 4 sound generators OUTPUTS None CALLS None CALLED BY POWER UP NOTES Only the Accumulator 15 affected 15 PLAY IT ADDRESS 1FF1 INPUT B song number to play FUNCTION S If the song is already playing do nothing Otherwise Load 1 note and set NEXT NOTE PTR Update channel data pointers OUTPUTS None CALLS PT IX TO SxDATA LOAD NEXT NOTE UP CH DATA PTRS CALLED BY Under user program control NOTES None 16 SOUND MAN ADDRESS 1FF4 INPUT None FUNCTION S Update all song data areas OUTPUTS None CALLS Update counters decrement sound duration and sweep timers Apply sound effect modify swept frequency and attenuation values Call special effects routines where necessary Update the channel data area pointers if necessary Restart the sound if indicated PT IX TO SxDATA PROCESS DATA AREA CALLED BY Under user program control Should be called every VDP interrupt after PLAY SONGS NOTES None 17 UP CH DATA PTRS INPUT None FUNCTION S Set all 4 channel data pointers to dummy inactive area Scan all song data areas to store song data area s byte 0 address to proper channel data pointer OUTPUTS None CALLS PT IX TO SxDATA CALLED BY JUKE BOX local routine name for PLAY IT EFXOVER sub routine in PROCESS DATA AREA NOTES IX returned intact 18 PROCESS DATA AREA
103. INPUT IX address of byte 0 of a song data area FUNCTION S If byte 0 is inactive code FF do nothing If byte 0 is special sound effect code do thru effect Otherwise process attenuation and frequency sweep data 1 any If note 15 over run sub routine EFXOVER OUTPUTS None CALLS AREA SONG IS ATN SWEEP FREQ SWEEP EFXOVER CALLED BY SND MANAGER local routine name for SOUND MAN NOTES None 19 EFXOVER INPUT IX address of byte 0 of a song data area FUNCTION S Load next note and update channel data pointers if needed OUTPUTS None CALLS LOAD NEXT NOTE UP CH DATA PTRS CALLED BY PROCESS DATA AREA NOTES None 20 PLAY SONGS ADDRESS 1F61 INPUT None FUNCTION S Prepare and pitch the actual song notes to sound chip Current frequency and attenuation data is output to each tone generator 1f sound on that channel is active otherwise that generator 15 turned off Noise generator is sent current attenuation data and control data if new Modifes SAVE CTRL if necessary OUTPUTS None CALLS TONE OUT UPATNCTRL UPFREQ CALLED BY Under user program control Should be called every VDP interrupt before SOUND_MAN NOTES None 21 TONE OUT INPUT IX pointer to byte 0 of a song data area A formatted channel mute code C formatted channel attenuation code needed for UPATNCTRL MSN D formatted channel frequency code needed for UPFREQ MSN FUNCTIO
104. ITE ORDER push af ld iy VRAM ADDR TABLE ld e 1y 000H ld d iy 001H ld a e out CTRL PORT a ld a d or 040H out CTRL PORT a pop af OUTPUT LOOP TABLE MA ld hl LOCAL SPR TABLE ld ix 000H inc ix 1 b 000H add RLi bcC add hl be add hl bc add hl bc ld b 004H id C DATA PORT OUTPUT LOOP10 outi nop delay nop nz OUTPUT LOOP10 dec a jr nz OUTPUT LOOP TABLE MA ret 163 DRIVERS FOR 9928 VDG The video drivers provide a standard protocol for the low level communication with the 9918 28 VDP There are four basic driver routines which between them allow the programmer to write a value to a VDP register read th VDP status register write a RAM or ROM buffer to a specified address in VRAM and read a RAM buffer from a specified address in VRAM The four routines outlined above are 5 Procedure Reg Writ H Reg Write takes a VDP register number 0 7 in the B register and byte value to written to it in the C register It writes the value to the given VDP register and returns If the specified register is one of the VDP mode control registers H ie 0 or 1 the Reg Write also writes the given value to th corresponding half of the VDP More Word in RAM All mode dependant decisions made by the operating system are made by referencing the contents of this word Thus it is important for the cartridge programmer to maintain it should he she choose not to use
105. If it contains the pattern 55AAH the OS assumes that a test cartridge is present bypass Coleco logo screen LOCAL SPR TABLE EQU 08002H This is a pointer to the CPU RAM copy of the sprite name tabl Th table copy is used whenever one level of indirection is desired in addressing the VRAM tabl For example when using the OS sprite multiplexing software SPRITE ORDER EQU 08004H This is a pointer to the CPU RAM sprite order table This table is used to order the local sprite name table WORK BUFFER EQU 08006H This is a pointer to a fr buffer space in RAM The object oriented graphics routines used this buffer for temporary storage CONTROLLER MAP EQU 08008H This is a pointer to the controller memory map that is maintained by the high level controller scanning and debounce software START GAME EQU 0800AH This is a pointer to the start of the game RESTART AND INTERRUPT VECTORS RST 8H RAM EQU 0800CH This is the restart 8 soft vector RST 10H RA EQU 0800FH This is the restart 10 soft vector RST 18H RA EQU 08012H This is the restart 18 soft vector RST 20H RA EQU 08015H This is the restart 20 soft vector RST 28H RA EQU 08018H This is the restart 28 soft vector RST 30H RA EQU 0801BH This is the restart 30 soft vector IRQ INT VECTOR EQU 0801EH This is the maskable interrupt soft vector NMI INT VECTOR EQU
106. LE These symbols are entry points to OS 7 routines They can be dirrectly called by programmers Legend P at the end special entry points for Pascal programs 1 61 1F64 1F67 1F6A 1F6D 1F70 1F73 1F76 1F79 1 7 1F82 1F85 1F88 1F8B 1891 1794 1797 1F9D 1FAO 1FA3 1FA6 1 9 1 lFAF 0300 0488 06C7 1D5A 1D60 1D66 1D6C 114A 118B 1979 1927 18D4 18E9 116A 1BOE 1B8C 1 10 1C5A 1C76 OF9A OFB8 1044 10BF 1 1CED 1D2A 0655 PLAY_SONGS ACTIVATEP PUTOBJP REFLECT VERTICAL REFLECT HORIZONTAL ROTATE 90 ENLARGE CONTROLLER SCAN DECODER GAME OPT LOAD ASCII FILL VRAM MODE 1 UPDATE SPINNER INIT TABLEP GET VRAMP PUT VRAMP INIT SPR ORDERP WR SPR NM TBLP INIT TIMERP FREE SIGNALP REQUEST SIGNALP TEST SIGNALP WRITE REGISTERP WRITE VRAMP READ VRAMP INIT WRITERP 1FB2 1FB5 1FB8 1FBB 1FBE 1 1 4 LECT 1FCA 1FCD 1FDO 1FD3 1FD6 1FD9 1FDF lFE2 E 1 1 7 1FFA 1FFD 180 0203 0251 1B08 1BA3 1C27 1C66 1C82 OFC4 1053 10CB 0F37 023B 1CCA 1 57 1001 1031 SOUND INITP LAY ITP VRAM UT VRAM IT SPR ORDER EST SIGN
107. LOR MODE 2 8 SET COUNT ld SAVED COUNT iy ld ix VRAM ADDR TABLE ld ld b 000H cp 004H nz COUNT10 ld a VDP MODE WORD bit 1 jr z SET COUNT20 SET COUNT10 ld iy SHIFT CT add iy bc id 1y 000H cp 000H jr z SET COUNT20 ADJUST INDEX sla e dec a JE nz ADJUST INDEX END ADJ INDEX push bc id bc SAVED COUNT ET VRAM for writes 160 ld a 1y 000H cp 000H jr z END ADJ COUNT ADJUST COUNT sla rl b dec a jr nz ADJUST COUNT ld SAVED COUNT bc END ADJ COUNT pop bc SET COUNT20 push hl add ix bc add ix bc id l ix 000H ld h 1 001 add hl de ex de hl pop hl 1 SAVED COUNT ret SHIFT CT db 002H db 003H db 000H db 003H db 003H PROCEDURE PUT VRAMO TABLE CODE BYTE START INDEX BYTE SLIC VAR DATA BUFFER ITEM COUNT INTEGER PUT VRAM P dw 00005H dw 00001H dw 00001H dw 00001H dw OFFFEH dw 00002H PUT VRAMQ ld bc PUT VRAM P ld de PARAM AREA call ld a PARAM AREA ld de PARAM AREA 1 ld iy PARAM AREA 5 ld hl PARAM AREA 3 PUT_VRAM_ Desc Writes a certain number of bytes to VRAM H from a buffer Input TABLE CODE in A 0 5 NAME TABLE 1 SPRITE GENERATOR TABLE 2 PATTERN NAME TABLE 3
108. Mode 0 Graphics I Description 32x24 characters two colors per 8 characters sprites active Mode 1 Text Description 40x24 characters 6x8 colors set in control register 7 sprites inactive Mode 2 Graphics II Description 32x24 characters 256x192 pixels two colors per line of 8 pixels sprites active Special meaning for CT and PG At control register 3 only bit 7 CT13 sets the address of the color table address 0000 or 2000 Bits 6 0 are an AND mask over the top 7 bits of the character number At control register 4 only bit 2 PG13 sets the address of the pattern table address 0000 2000 Bits 1 and 0 are an AND mask over the top 2 bits of the character number If the AND mask is 00 only one set the first one of 256 characters is used on screen 01 middle of the screen 8 rows use another set the second one of 256 characters e 10 the bottom of the screen 8 rows use another set the third one of 256 characters 11 three set of 256 characters are used on screen set at the top 8 rows set two in the middle 8 rows and set three at the bottom 8 rows This particular mode is normally used as a bitmap mode screen The bitmap mode screen is in fact all three characters sets top middle and bottom showed on screen at the same time by filling the screen with all the characters Mode 3 Multicolor Description 64x48 big pixels 4x4 sprites active 199 SPRITES
109. N 1FF4 Update sound tables by applying sweep effects loading next note or set the END flag The song table in ROM is composed into many entries of two addresses a pointer to the song data in ROM and a pointer to the song data area in RAM Each entry correspond to a song The 1 entry in the song table have to use obligatory a pointer to the 1 song data area The memory allocation to a free zone in RAM for the song data areas 1s the responsibility of the coder Because the sound chip can t play more than one song on the same sound channel there 1s a concept of priority higher is the number of the song data area higher is the priority Each song in ROM is encoded into a specific sound data format uses only one channel and obligatory ends with an END or REPEAT code To play a music that uses more than one sound channel the coder have to encode his music into separate song entries one for each sound channel needed of course that needs more than one song entry in the song table where each entry uses a different song data area Expert tips To stop a song playing you can play another song that uses the same song data area or write the INACTIVE code OFFh at the 1 byte of its song data area 24 OBJECT ROUTINES The following routines are for objects An object can be represented as a set of characters and or sprites Note Almost every Non Coleco programmers didn t use these routines Object graphic is a good concept but these routi
110. N S Pitch the current frequency and attenuation to sound chip OUTPUTS None CALLS UPATNCTRL UPFREQ CALLED BY PLAY SONGS NOTES None 22 LOAD NEXT NOTE INPUT IX pointer to byte 0 of a song data area FUNCTION S Update song data area based on next note code OUTPUTS None CALLS JUKE BOX local name for PLAY IT Note is called only to reload 1 note when reading a REPEAT note code CALLED BY PLAY IT EFXOVER NOTES AF HL DE BC and IY are affected Additional may be changed by called special effect subroutines 23 QUICK REFERENCE HOW TO USE THE OS 7 SOUND ROUTINES When needed usually before playing game turn off sound with the following routine TURN OFF SOUND 1206 Turn off all sound channels No setup requiered Setup the sound tables in RAM as soon as possible in your code with the following routine SOUND INIT 1 Initialize sound tables in CPU RAM Input HL Address of the song table B Number of output tables to be used Note The first entry in the song table in the game code contains the address of the 1 song data area in RAM During the game use the following routine to play sounds PLAY IT 1FF1 Play a specific song or sound effect Input B Song number to be started And to play songs at a regular speed add the following routines in this order in the user NMI routine PLAY SONGS 1F61 Pitch data to sound generator chip SOUND MA
111. OLOR Desc Gets th color information from the 15 appropriate place in vram GET COLOR ld a 004H exx push de exx pop de ld hl WORK BUFFER 1 iy 00001H call VRAM ret PUT COLOR Desc Puts the color information in the appropriate place in vram PUT COLOR 1 a 004H exx push hl exx pop de id hl WORK BUFFER ld iy 00001H call _ ret 172 EXPANSION ROUTINES 5 Define BYTE COUNT SOURCE DESTINATION Global GLB AGNIFY O UADRULE EQU BC register EQU IX register EQU IY register The routines in this module take a single 8 byte block as input produce 4 8 byte blocks as output They perform a 2 to 1 expansion and a simple quadrupling operation respectively MAGNIFY Desc Perform a 2 to 1 expansion on an 8 byte block of data Input HL Source pointer DE Destination pointer Destroy IX IY AF BC DE HL MAGNIFY push pop push pop ld MAG LOOP ing ld rl rl rl El dec jr ld rl rl rl El QUADRUPLE hl ix de iy bc 00008H a 1 000 ix d a 004H nz EXP 2 iy iy iy iy iy iy bc b F000H h F010H 1 F000H h F010H 1 nz MAG LOOP oy Desc Perform a quadrupling on an 8 byte block of data Input HL Sourc DI pointer E Destination pointer 173 De
112. OTHING INSTALLED AT BOOT UP THE SOFTWARE MUST PERFORM THE FOLLOWING INITIALIZE THE INTERRUPT VECTORS B INITIALIZE RESTART VECTORS 4 C TURN OFF THE SOUND CHIP D DETERMINE IF A CARTRIDGE IS PLUGGED IN IF SO BRANCH TO THE CARTRIDGE PROGRAM ELSE WAIT FOR CARTRIDGE FALSE EQU 0 TRUE EQU 1 VALUES FOR BOOLEAN FLAGS BEGIN OF POWER UP POWER UP IF CARTRIDGE 55AAH THEN EXIT TO START GAME TEST ld hl CARTRIDGE ld 1 055 jp nz NO TEST _ ld a h cp nz NO TEST ld hl START GAME jp h1 INFO index jump ELSE NO TEST TURN OFF SOUND CHIP call TURN OFF SOUND INITIALIZE RANDOM NUMBER GENERATOR ld h1 00033 ld RAND NUM hl CLEAR CONTROLLER BUFFER AREAS call CONTROLLER INIT DEFER WRITES FALSE ld 000H ld DEFER WRITES a MUX SPRITES FALSE 1 SPRITES a EXIT DISPLAY LOGO AND TEST FOR CARTRIDG jp DISPLAY LOGO COMMON PARAMETER PASSING ROUTINE PASCAL functions parameters to CPU RAM complex BEGIN OF PARAM _ PARAM _ pop hl ex sp hl push hl ld a bc id l a inc be ld a bc inc bc 1 69 L00A3 L00B7 100 4 10000 10006 LOODA pop inc inc push e
113. PAT POS of BACKGROUND 12h EQU 17 X PAT POS of BACKGROUND 28 Start of background pattern generators 1Ch EQU 100 Start of object s pattern generators 64h 132 Start of background color generators 84h iy WORK BUFFER Get start of free buffer area a VDP MODE WORD Find out which graphics mode we are in 116 bit 1 jr nz ELSEl res 1 jr END1 ELSE1 7 set 7 5 1 iytFLAGS b push hl ld h ix 003H ld 1 002 a hl 1 iy FRM a xor 080H ld hl a inc hl id e hl rA a e and 007H neg add a 008H from next pat boundary id iy XDISP a inc hl id d 11 call PX TO PTRN POS id 1 BK e inc hl id e hl ld a e and 007H 1 iy YDISP a inc hl ld d hl call PX TO PTRN POS ld 1 BK e Now get the nin the mobile 1 ld id id call Read PM2 Y 2 Else Save Then Mode I Mode II Save Selector Save graphics address HL ADDR of status Get frame 4 And save Complement table in use flag Save back in status area point to X LOCATION E Low X LOCATION Pixels to right of pattern boundary Amount to shift pattern left Save DE X LOCATION Calculate X PAT POS of background And Save Point to Y 1 E Low Y LOCATION
114. R 6 272 1 een rebas D D A DD ELLE 47 CONTROLLER TI eo odes DL DU Lc ete o lal UI aS Oneal a ante 48 CONI READS M pire 4 Em Dace 49 CONTROLLER SCAN Get a eid Lei cesta QR EIUS 50 UPDATE SPIBINER cls bac ui aA M Ute De UM 51 DECUDER X succi e ah act ELLA CE Satin 52 MISCELLANEOUS desciende n eeu rM Mu ss meal E ala at EE 53 Io rubo NM 54 uc M MR 55 POWER Sat 56 DECEBN Soc erat sas ait Nui its 57 iE Lud dme a M a 58 MSNTOLS DL PR ML al D E d 59 us Aceh rM eed ek RE 60 DISPLAY LOGO ite EA d A E 61 OS T ABSOLUTE LISTINGS S So eMe rere e RU ol UA ME 62 OPERATING SYSTEM e S E A A E 63 BOOL DB e EA Ser t IPE 66 Ue eser M LA LM ELA 68 AMERICAS esie an d E dE 68 ASCI TABE ES ott MC
115. R inc hl Go to next table location ld hl e Store timer length inc hl id hl e Store timer length again in case of repeat jr INIT TIMER EXIT All done so let s exit LONG TIMER set LONG hl Set long timer bit ld Check for long repeat timer or a jr 2 A LONG REPEAT If zero then go to non repeating timer push de Store timer length temporary ex de hl Swap registers ld hl NEXT TIMER DATA BYTE To get free space in long timer table ex de hl Then swap back set REPEAT hl Set mode byte to repeating inc hl ld nl e Store low byte of timer address into the value word inc hl ld hl d Store high byte of timer address ex de hl Move address of data area into HL pop de Get back the length of timer ld hl e Store that in the data table inc hl 1 hl d inc hl 1 1 Store it again inc hl 1 hl d inc hl ld NEXT TIMER DATA BYTE hl Store the next available data area for future use jr INIT TIMER EXIT NOT A LONG REPEAT T inc IMER2 id inc ld inc jr EXT TIMERI bit jr inc hl 1 Store it again hl hl d hl INIT TIMER EXIT EOT 1 nz MAKE NEW TIMER hl Go to next mode byte 136 inc inc inc jr hl hl TIM MAKE NEW TIMER push push inc inc inc inc ld ex pop res ex pop jr INIT TIMER EXIT pop re
116. R Or 80n ld l ix GRAPHICS id h ix GRAPHICS 1 ld de FRAME TABLE PTR add hl de HL FRAME TABLE PTR ex de hl ld a de ld l a inc de ld a de ld h a HL FRAME TABLE PTR push hl 1 l 1x STATUS 1 h 1x STATUS 1 ld de FRAME add hl de HL FRAME ld a hl Calculate offset of sla a COLOR entry ld bc 00000H ld hl add hl bc HL COLOR id a hl Or in 80h 080H ld iy COLOR AND TAG a jp PUT Y AND NAME Else Continue below Begin PUTISPRITE PUTISPRITE id iy WORK BUFF pel SPRITE PTR WORK BUFFER 112 With THIS SPRITE SPRITE PTR DO If STATUS X LOCATION 32 And STATUS X LOCATION 256 And STATUS Y LOCATION gt 32 And STATUS Y LOCATION 192 Then ld l i4x STATUS id h 1x STATUS 1 ld de X LOCATION add hl de HL X LOCATION id C hl inc hl ld b hi BC X LOCATION ld a b Compare BC with 32 cp 000H jr z OK 3 cp OFFH 2 jp nz DONT PUT ld cp OEIH 31 jp m DONT PUT OK 3 inc hl HL Y LOCATION 1 ey Chil inc hl ld b hl BC Y LOCATION ld a b Compare BC with 32 cp 000H z OK 4 OFFH 1 jp nz DONT PUT ld cp 31 m DONT 4 If STATUS X LOCATION lt 0 Then dec 1 hl HL HI X LOCATION ld a
117. RK BUFFER Pointer to fr buffer space in RAM 8008 8009 CONTROLLER MAP Pointer to controller memory map 800A 800B START GAME Pointer to the start of the game 800C 800E RST 8H RA Restart 8h soft vector 800F 8011 RST 10H RAM Restart 10h soft vector 8012 8014 RST 18H RAM Restart 18h soft vector 8015 8017 RST 20H RAM Restart 20h soft vector 8018 801A RST 28H RAM Restart 28h soft vector 801B 801D RST 30H RAM Restart 30h soft vector 801E 8020 IRO INT VECTOR ask able interrupt soft vector 38h 8021 8023 NMI INT VECTOR Non mask able interrupt NMI soft vector 8024 80XX GAME NAME du eR UAE 183 COMPLET OS 7 RAM ADDRESS NAME DESCRIPTION 7020 7021 PTR LST OF SND ADDRS Pointer to list in RAM of sound addrs 7022 7023 PTR TO 5 0 Pointer to song for noise 7024 7025 PTR TO S ON 1 Pointer to song for 1 1 7026 7027 PTR TO 5 2 Pointer to song for 1 2 7028 7029 PTR TO S ON 3 Pointer to song for 1 3 702A SAVE CTRL CTRL data byte 73B9 STACK Beginning of the stack 73BA 73BF PARAM AREA Common passing parameters area PASCAL 73C0 73C1 TIMER LENGTH Length of timer 73C2 TEST SIG NUM Signal Code 73 3 73 4 VDP MODE WORD Copy of data in the 15 2 VDP registers 4365 VDP STATUS BYTE Content
118. Rr GR HEP e Oe taped te eer ee 2 OS 7 ROUTINES SPECIFICATION S onines aa e EP 5 D e Pre e re ri bee e 6 9 datore dint bee ee ere ner e i 7 AIN SV Di 8 UPATNGIRLE RO eta a eI RR ee M S 9 teret atten etta etui S eM 10 PrE TESDA a e neat taedet mem EEAVE CBFPEEGT nee ote e Meer ER 12 ARBAZSONGIS Re P ee PIRE PEE eu ene AS RE VEN ONCE 13 SOUND AN 5 iet e tete reet e e doe re nds hang re TEES 14 TURN OFF SOUND ea S ene Minera s 15 gb VHS 16 NOBIPEZE NMEE 17 UP CH DATAPERS t ERA SWR 18 PROCESS AREA niece e ee e ee ei 19 EEXOVER Beet che 20 PLAY SONG 21 TONE OU ced decdvecbentevcel RA 22 LOAD NEXT eee ee ee es Pete eee P EA 23 QUICK REFERENCE HOW TO USE THE OS 7 SOUND
119. S MANAGER 30 e te M D M M dents DM 83 SND ue cen c 83 UP CH DATA PTRS ec shoe cect M EM 83 PROCESS DATA AREA 84 ER OON n e ELM Lu M E 84 PLAY SONG Rei ate conta 86 BIA ONCE C DEUM EM Luis 86 LOAD NEXT NOTE E LA E ML Ei DR MU DUE IU 88 LOAD NEXT NOTE deu RUD S 88 MADE 92 M LE neha A e E LE 93 ACTIVATE oerte AEM Mta ME MERIT UE 93 PUT DERRD BUT scorsa dudes st D ea LM 99 INIT OU ses ea Dt DM E D E 100 INIT OUEUB e elu Mes Me RAT 100 WRITER EPOD METER 100 PUILOBIO M I M EOM qM 102 dien acne sate M atta ee e hoe 102 e e Le e 103 PULSEME Ede gu C Mie 103 e a vcn OE ae tak AL 106 GEI PKO N s oim de ein ed Dub 108 PUEZSPRIDERIN
120. Sprite multiplexing solution to the 5th sprite problem if RAND NUM EQU 073C8H 2 bytes This is the shift register used by the random number generator It is initialized at power up 72 SOUND ROUTINE EQUATES EQUATES E Operating System Sound Routine H FILE NAME OSSR EQU Equates Dedicated Cartridge RAM locations EDAREA EQU 07020H DEDAREA is the s tart of the RAM area dedicated to sound routines PTR TO LST OF SND ADDRS EQU 0 PTR TO S ON 0 EQU DEDAREA 2 PTR TO S ON 1 EQU DEDAREA 4 PTR TO S ON 2 EQU DEDAREA 6 PTR TO S ON 3 EQU DEDAREA 8 SAVE_CTRL EQU DEDAREA 10 data to sound chip thru this port special sound effect code Attenuation level codes OFF EQU 00 no sound Sound output port SOUND PORT EQU OFFH H Special byte 0 codes INACTIVE EQU OFFH SEFFECT EQU 62 ENDSDATA EQU 0 Offsets within an SxDATA song data area CH EQU 0 channel SONGNO EQU 0 song number NEXTNOTEPTR EQU 1 FREQ EQU 3 frequency ATN EQU 4 attenuation CTRL EQU 4 NLEN EQU 5 noise FPS EQU 6 frequency sweep FPSV EQU 6 FSTE EQU 7 ALEN EQU 8 attenuation sweep ASTEP EQU 8 APS EQU 9 APSV EQU 9 Song end codes CHOEND EQU 1 EQU 050H CH
121. TART INDEX SLICE in DF DATA buffer address in HL ITEM COUNT passed in IY ke kc kc e ke ko e e ke e PROCEDURE BODY KKK Global GLB PUTOSPRITE PUTISPRITE 21 Begin PUTOSPRITI PUTOSPRITE id iy WORK BUFFER SPRITE PTR WORK BUFFER With THIS SPRITE SPRITE PTR DO If STATUS X LOCATION 8 And STATUS X LOCATION 256 And STATUS Y LOCATION gt 8 And STATUS Y LOCATION lt 192 Then 1 l ix STATUS 1 h ix STATUS 1 1 de X LOCATION add hl de HL X LOCATION id C hl inc hl ld b hl BC X LOCATION ld a b Compare BC with 8 cp 000H jr z OK 1 cp OFFH 1 jp nz DONT PUT 111 ld a c cp OF9H PEL jp m DONT PUT OK 1 inc HL Y LOCATION id 1 inc hl ld b hl BC Y LOCATION id a b Compare BC with 8 cp 000H jr z OK 2 cp OFFH 1 jp nz DONT PUT ld OF9H z 7 jp m DONT_PUT OK 2 If STATUS X LOCATION 0 Then dec hl dec hl HL HI X LOCATION ld a hl Compare with 0 cp 000H jp z CONTINUE X BYTE STATUS X LOCATION 8 dec hl HL X LOCATION id c hl inc hl ld b hl 1 h1 00008H add hl bc id 1 id iy X a COLOR AND TAG GRAPHICS FRAME TABLE STATUS FRAME COLO
122. TATE EQU KBD OLD EQU 008H KBD STATE EQU Defines PORTS STRB RST PORT EQU OCOH STRB SET PORT EQU 080H CTRL 0 PORT EQU OFCH CTRL 1 PORT EQU OFFH Global GLB CONTROLLER INIT 7 GLB CONT READ 7 GLB CONT SCAN GLB UPDATE SPINNER _ GLB DECODER GLB POLLER DEC KBD TBL db KDB db 006H db 001H db 003H db 009H db 000H db KDB 002H db OOBH db 007H db KDB db 005H Decoder table for k NULL Initialize controller to strobe reset Controller read routine Controller scanner routine Update spinner switch routine Decodes raw undebounced data Polling routine for all devices in controller yboard keypad 6 11 0 12 Ht 17 5 139 db db db 004H 14 008H 8 KDB NULL CONTROLLER INIT Initialize controller to strobe reset ou 1 1 1 jr ELAY Controller STRB r a ix CONTROLLER_MAP 1 iy DBNCE BUFF b NUM DEV 2 Clear contro ller memory and debounce status buffer 1 000 ix iy 000H a iy 000 e iy b Clear remain S0 C1 S1 Delay after P t a 51 C0 a a ing variables SPIN SWO CT a SPIN 571 CT a S0 C0 a
123. TR 1 ixt 002H h move new note data and fill in bytes where necessary dec hl point HL back to 1st ROM data to move ld de 00005H point DE to destination bytes 5 4 and 3 call DE TO DEST ld bc 00003H move 3 bytes lddr ld ix FSTEP 000H set for no freq sweep ld ixtASTEP 000H Set for no atn sweep jr MODBO cp 001H test for type 1 if psw is zero note is type 1 swept freq fixed attenuation jr 117 CASE not type set up N 1 EXT NOTE PTR id 006H note after this note is 6 bytes away ld 000H pt HL to it add hl de ld ix 001H 1 store in NEXT NOTE PTR ld ix 002H h move new note data and fill in bytes where necessary dec hl point HL back to 1st ROM data to move FSTEP inc e 7 point DE to destination bytes 7 3 call DE TO DEST ld bc 00005H move 5 bytes lddr ld ix ASTEP 000H Set for no atn sweep jr MODBO cp 002H test for type 2 TE psw is zero note is type 2 fixed freq swept attenuation nz TYPE3 CASE note type 2 set up NEXT NOTE PTR ld 006H pt HL to note after this note 6 bytes away id 000H pt HL to it by adding 6 add hl de pop af header this note CH SONGNO push af put back on stack and mask SONGNO leaving CHf if psw is zero This is a noise note which is only 5 ROM bytes long
124. TTERN NAME TABLE Jeeeeeeeex ld hl LINE 1 id de 00025H ld iy 00016H ld 002H call PUT VRAM ld hl LINE 2 ld de 00065H ld iy 00017H id 002H call PUT VRAM ld de 000C5H call WRITE L3 ld de 00105H call WRITE L3 ld de 00145H call WRITE L3 ld de 00185H call WRITE L3 ld de 001E5H 155 call WRITE L3 1 de 00225H call WRITE L3 ld de 00265H call WRITE L3 ld de 002A5H call WRITE L3 ld de 00105H call WRITE L4 ld de 00145H call WRITE L5 1 de 00185H call WRITE L6 ld hl LINE 7 ld de 001E5H call WRITE CHAR ld hl LINE 8 1 de 00225H call WRITE CHAR ld hl LINE 9 1 de 00265H call WRITE CHAR ld hl LINE 10 ld de 002A5H call WRITE CHAR ld de 0010FH call WRITE L4 ld de 0014FH call WRITE L5 1 de 0018FH call WRITE L6 ld de 001F1H call WRITE L11 1 de 002315 call WRITE 111 ld de 00271H call WRITE 111 1 de 002B1H call WRITE L11 ld de 0022FH call WRITE L4 1 de 0026FH call WRITE 15 ld de 002AFH call WRITE L6 1 de 001FBH call WRITE L12 ld de 0023bH call WRITE L12 1 de 0027BH call WRITE L12 ld de 002BBH call WRITE L12 JoeB Write out COLOR NAME TABLE Note White 4 Blue _ E ld hl COLORTABLE ld de 00020H ld a OF4H call FILL VRAM ck ck ck ck ckckockckckck ck kckck kk Enable display
125. UT SPR Else DONT PUT Put sprite off th GET 0 5 SPRITE SPRIT push iy push ix push iy push iy xor a ld d 000H ld 4x SPRITE INDEX pop hl iy 00001H call GET VRAM SPRITE PTR X 0 1 a 000H pop iy id iy X a SPRITE PTR COLOR AND TAG 80 1 a 080H ld iy COLOR AND TAG a PUT VRAM 0 5 PRITE SPRITE 1 000 1 1 5 INDEX hl ld iy 00001H call PUT VRAM End if End PUTOSPRITE EXIT PUT SPR ret Count of one item 115 PUT MOBILE pKCEOCKkckckk ke ke ke ke e MODIFIED VERSION TO RUN ON HP ASSEMBLER Ck ck ckckckck ck k ck k kk kkk P 4 16 82 13 50 00 CK Ck Ck Sk ck Ck ck kk Ck kk Ck ck kk ck kk Ck kk Ck kk kk Sk kk Sk kk Sk ko kc kckock kk ck kk DESCRIPTION This procedure places a mobile object on the pattern plane at the X Y pixel localisation specified in that objet s RAM Status AREA A buffer area of 204 bytes gaphics mode I grap hics mode II or 141 bytes is required for forming the new generators representing the object on it s background the procedure uses RAM starting at F BUF SPACE for this buffer IX Address of object to be processed HL Address of object s graphics tables in ROM with background generators Selector for me
126. XT VDP MODE WORD EXT SPRITES EXT PARAM _ EXT LOCAL TBL SPRITE ORDER Global GLB INIT TABLE GET VRAM PUT VRAM INIT SPR ORDER WR SPR NM TBL GLB INIT TABLEQ GET VRAMQ PUT SPR ORDERO WR SPR NM TBLO DATA PORT EQU OBEH CTRL PORT EQU OBFH PROCEDURE INIT TABLEQ TABLE CODE BYTE TABLE ADDRESS INTEGER INIT TABLE P dw 00002H dw 00001H dw 00002H INIT TABLEQ ld bc INIT TABLE P id de PARAM AREA call ld a PARAM AREA hl PARAM AREA 1 INIT TABLE Desc Initializes the table addresses for VRAM tables E Writes the appropriate base address into the respective VDP register INIT TABLE ld ld b 000H ld ix VRAM ADDR TABLE add ix bc add ix bG ld ix 000H 1 ld ix 001H h ld a VDP MODE WORD bit 1 jr z INIT ld a c cp 003H jr z CASE OF GEN cp 004H jr z CASE OF COLOR jr INIT TABLE80 CASE OF GEN 1 b 004H ld 1 158 jr nz CASE OF GEN10 id c 003H jr INIT TABLE90 CASE OF 10 id c 007H jr INIT TABLE90 CASE OF COLOR id b 003H ld 1 jr nz CASE OF CLR10 ld 07 jr INIT TABLE90 CASE OF CLR10 ld OFFH jr INIT TABLE90 Compute base address BAS Get bit shift count INIT TABLE80 id iy BASE FACTORS add iy bc add iy bc DIVIDE INIT TABLE90 BAS PROCEDURE GET VRAMO TABLI E ld a 1
127. a Ge Re Else increment BC to spinner 1 t spinner switch count turn it in E Clear out device data for player Ge t other device data for player Save it Mask out joystick data Re turn it in L Restore data Mask out fire button data Re turn it in H Strobe segment 1 Read segment 1 player data Save it Reset back to segment 0 Mask out keyboard data Get decoder tabl address Compute offset Return keyboard data in L Restore data Mask out ARM button data Return it in H Polling routine for all devices in controller POLLER call CHK SEG call CHK PLYR 1 pop CONT SCAN iy DBNCE BUFF ix CONTROLL ix a ix 000H 7 a z CHK PLYR 1 b a de PLYR_0 ix de SEG_0 z CHK SEG 01 50 CO ER hl SPIN SWO0 CT DECODE 0 a b SEG 1 z CHK PLYR 1 51 CO DECODE 1 ix Go scan all data first Debounce buffer pointer controller memory pointer Get player 0 status If player 0 is not active Then check player 1 Else player 0 is active Save status Compute address for player 0 CONTROLLER MEMORY If segment 0 is not active Then check segment 1 Else segment 0 is active Decode data for segment 0 Restore player 0 status segment 1 is not active Then check player 1 Else segment 1 is active Decode data for segment 1 142
128. a area FUNCTION S OUTPUTS Z flag 15 set if sweep 15 over or note was never sweep Z flag is reset sweep progress CALLS DECLSN MSNTOLSN CALLED BY PROCESS DATA AREA NOTES None UPATNCTRL INPUT IX address of byte 0 of a song data area C formatted channel attenuation code MSN FUNCTION S Output attenuation or noise control data to sound port OUTPUTS None CALLS None CALLED BY PLAY SONGS TONE OUT NOTES None UPFREQ INPUT IX address of byte 0 of a song data area D formatted channel frequency code MSN FUNCTION S Output frequency data into 2 bytes to sound port OUTPUTS None CALLS None CALLED BY TONE OUT NOTES None 10 PT IX TO SxDATA INPUT B song number FUNCTION S Point IX to byte 0 in a song data area calculated with song number SONGNO passed in B OUTPUTS IX address of byte 0 song data area used by that song number SONGNO CALLS None CALLED BY FREQ SWEEP NOTES DE HL is pointing to MSN SxDATA entry in LST OF SND ADDRS LEAVE EFFECT INPUT B song number FUNCTION S Restores the SONGNO to which the effect note belongs to B5 BO of byte 0 in the effect s data area and loads byte 1 and 2 with the address of the next note in the song The address of the 1 byte SONGNO saved by the effect when it was first called is passed to DE The 2 byte address of the next note in the song also saved by the effect is pas
129. a byte of data to or from VRAM it takes approximately 2 microseconds until the VDP is ready to make the data transfer In addition to this delay the VDP must wait for a CPU access window 1 the period of time when the VDP is not occupied with the memory refresh or screen display and is available to read or write data Summary of these delay times in microseconds are showed in the following table Screen Mode Condition VDP Delay Time waiting for an access window Total Time Graphics I II x 0 M2 Active Display Area 2 0 5 95 na Active Display Area 2 0 1 1 a Active Display Area 2 0 1 5 All Screen is Blanked 2 0 4300 microseconds All after Vertical 2 0 Interrupt Signal The worst case time between windows occurs during the Graphics I or II screen mode when sprites are being used Two situations occur where the time waiting for an access window is effectively zero 1 Screen is blanked by reseting the blank bit of register 0 2 VDP is in the vertical refresh mode This mode came right after the active display area period An interrupt output signal NMI indicates that the VDP is entering the vertical refresh mode and that for the next 4300 microseconds The program that monitors the interrupt output must allow for its own delays in responding to the interrupt signal NMI and recognize how much time it has left during the refresh period The CPU must set the interrupt enable bit GINT of Regis
130. a cartridge is present 1 Ifit s present Add game informations from cartridge to screen title company year Wait 10 seconds Turn off display and start game 2 Otherwise display default message during 60 seconds then turn off display OUTPUTS None CALLS FILL VRAM PUT_VRAM WRITE REGISTER MODE 1 LOAD ASCII START GAME CALLED BY POWER UP NOTES None 61 OS 7 ABSOLUTE LISTING OS 7 Listing from the ColecoVision Programmers Manual rev 5 O Coleco Industries Inc 1982 Disassembled with DASMx v1 30 Copyright 1996 1999 Conquest Consultants Restored by Daniel Bienvenu October 2004 62 OPERATING SYSTEM 3 Author Coleco Indutries Inc Advanced Research amp Development Software Engineering UserID OS Starting date A long long time ago in a galaxy far far away Prom release date 24 Nov 1982 For internal use only Prom release rev 7B A Prom release date December 28 1982 7 Prom release rev 7PRIME Header Rev 2 ck Ck KKK KKK CC Ck Ck KKK KK KKK KKK KKK KKK KKK KKK KKK kk kk Sk ck Sk Sk Mk Sk kv kx kv kv ko ko HE ColecoVision Operating System is no Absolute Listing REV 7PRIME ERG O Coleco Industries 1982 H SU Confidential E H cock ck ck ck ck kk ck ck kk Sk ck ck kk ck ck kk ck ck ck ck kk ck ck kk ck ck ck ck ck ck KKK KKK KKK ck ck ck kk ck
131. air has length of timer Acc has zero for repeating timer Signal number is returned in the REPEAT SIG CODE DEFS 1 TIMER LENGTH DEFS 2 REQUEST SIG PARAM dw 00002H dw 00001H dw 00002H REQUEST SIGNALQ ld bc REQUEST SIG PARAM ld de PARAM AREA S call PARAM_ ld hl TIMER LENGTH ld a PARAM 5 REQUEST SIGNAL 1 de hl ld hl TIMER TABLE BASE bit FREE 11 A jr 2 TIMERI push hl ld a hl and 010H 020H ld hl a Return any other value for a non repeating type Accumulator See if If not 135 Put Repeat Code into C register Put length of timer into DE Get Timer Base Address Into offset to First Table value current timer fr go get the next timer jr nz LONG TIMER RE FREE HL Reset free bit OR D Check for zero JR NZ LONG TIMER If non zero then it s a long timer RES REPEAT HL Set for a NON Repeating timer RES LONG HL LD Check for a short repeating timer or jr 2 A REPEAT TIMER Don t reset repeat bit in mode byte if non repeating set REPEAT hl Set repeat bit NOT A REPEAT TIME
132. ally until an interrupt occurs and performed in a block by central writer routine ck ck Ck Ck Ck Ck ck Ck Ck Ck Ck CC Sk Ck Ck Ck Ck CK Ck Ck ck Ck Ck Ck Ck ck Ck Ck Ck Ck CC Ck Ck Ck kk ck Ck Sk Ck ck kk kk ck kk kk ck Mk Sk ko ko KKK DATA QUEUE SIZE DEFS I 73CA This is the size of the defered write queue It is set by the cartridge programmer It has range 0 255 QUEUE HEAD DEFS 1 4 A3CB QUEUE TAIL DEFS 1 1306 These are the indices of the head and tail of the write queue HEAD ADDRESS DEFS 2 73CD TAIL ADDRESS DEFS 2 7 hese are the addresses of the queue head and tail w UFFER DEFS 2 2 1301 This is a pointer to the beginning of the defered write queue Th tridge programmer is responsible for providing a RAM area to hold the queue and passing its location and size to init queue 3 Q DEFER WRITES DEFS 1 73C6 Defines TRUE EQU 1 FLASE EQU 0 ev ET UP WRITE Values for boolean deferal flag Common PARAM AREA DEFS 3 73BA PARAM AREA is the common parameter passing area for PASCAL entry pts SET UP WRITE sets up defered VRAM operation Put data in QUEUE HEAD push ix 1 hl HEAD ADDRESS pop de 1 1 Put pointer hl
133. aphics mode is 2 then it reflects the corresponding color generators as well BEGIN REFLECT HORIZONTAL RFLCT HOR ld ix RLFCT HOR jr CONTINUE GRAPHICS PROCEDURE ROTATE 90 TABLE CODE SOURCE DE DESTINATION COUNT BC 168 rotates each of a block of g H H Fh fT copies the corresponding col BEGIN ROTATE 90 ROT 90 ld ix ROT 90 jr CONTINUE GRAPHICS PROCEDURE ENLARGE TABLE CODE SOURCE D enerators from VRAM 90 degrees clockwise the generators are from the pattern plane and the graphics mode is 2 then or entries as well E DESTINATION HL COUNT BC It takes each of a block of gen generators where each pixel of pixels in the new ones If the graphics mode is 2 then it also generators as well BEGIN ENLARGE ENLRG ld ix ENLRG_ CONTINUE GRAPHICS exx ex af af push ix MAIN LOOP ex af af push af ex af af pop af exx push de exx pop de 1 iy 00001H ld hl WORK BUFFER call push ix jp ix INFO RETURN HERE inc de dec bc ld a b e exx jr nz MAIN LOOP pop ix ret RLFCT VERT Desc Operations specific to t RLFCT VERT ld hl WORK BUFFER ld bc 00008H push hl pop de add hl bc ex de hl erat
134. art of string A 32 C DIV 2 h1 01700H de de a d e nz TIMER hl a h 1 2 154 GAME OPTION Displays the game option screen with white letters on a blue background VDP is left in mode 1 with the VRAM memory map as follows VDP MEMORY MAP 3800H 3FFFH SPRITE GENERATOR TABLE 2000H 201FH PATTERN COLOR TABLE 1BOOH 1B7FH SPRITE ATTRIBUTE TABLE 1800 PATTERN NAME TABLE 0000H 17FFH PATTERN GENERATOR TABLE External EXT VRAI EXT WRITE REGISTER EXT COLORTABLE EXT LOAD ASCII EXT FILL VRAM EXT MODE 1 Global GLB ckckck ck ck ck k kk k Display game option Screen x AME OPT Ck ckckckckckckckck ck k ck k KKK CLEAR 16K VRAM ck ck kk k id h1 00000H ld de 04000H ld 000H call FILL VRAM kCckckckck ckckckck Set up VDP with mode T ck ck ckckckckckck ck kck ck call MODE 1 KKKKKKKKKKKK Set up background color ck ck ckckockckckckck k ck Note 0 Black default background color White default forecolor not used in mode 1 ld 00 1 c 004H call WRITE REGISTER KAEKKKK ck kc kk Write out PATTERN GEN TABLE ckockckckckckckck call LOAD ASCII Weite out PA
135. ata address of spinner 0 count If int bit set spinner 1 If bit 5 is set going right Else left Decrement spinner counter Go check spinner 1 Right spinner increment counter Look at spinner 1 data If int bit set Then not spinner 1 bump HL Else spinner 1 If bit 5 is set ing right Else left Decrement spinner counter Right increment spinner counter Desc This routine returns decoded raw undebounced data may or not be required by 0 5 Input H Controller number E L Segment number Output SEGMENT 0 SEGMENT 1 H BYTE 1 FIRE ARM BYTE 2 JOYSTICK KBD E BYTE 3 SPINNE DECODER id 1 STROBE SET If L 1 then decode segment 1 7 5 Segment 0 FIRE BUTTON JOYSTICK Return H FIRE BUTTON L JOYSTICK E SPINNER Do spinner first id bc SPIN SWO CT ld a h cp CONTROLLER 0 If player 0 then go decod 141 1 E Segment 1 DEC 5 out call ld out and DECODERX z DEC PLYR CONT READ d a JOY MASK l a a d FIRE h a DECODERX ASK ARM BUTTON KEYBOARD Return H ARM BUTTON L KEYBOARD STRB S CONT READ d a ET PORT a STRB RST PORT a KBD MASK hl DEC KBD TBL 4 b 000H hl bc 1 hl a d ARM MASK h
136. controller port data bits 1 mean data bits 0 mean no data Destroys A 50 UPDATE SPINNER ADDRESS 1 88 INPUT None FUNCTION S Update counters pointed by SPIN SWO CT and SPIN SWI CT by reading bit 4 and 5 from segment 1 of both controller ports OUTPUT None CALLS None CALLED BY Under user program control NOTES Destroys A HL 51 DECODER ADDRESS 1F79 INPUT Controller number 0 for player 1 1 for player 2 L Segment number 0 for fire joystick 1 for arm keyboard FUNCTION S If L segment number 0 Load spinner counter SPIN SWO0 CT or SPIN SWI CT in E Call CONT READ Load joystick data in L A AND OF Load Fire state in H A AND 40 Else L segment number 1 OUTPUT Call CONT READ Load decoded key value in L 0 key 0 9 key 9 A key key no key Load Arm state in H A AND 40 State of Fire 1f segment number 0 Arm if segment number 1 L State of Joystick 1f segment number 0 Keyboard if segment number 1 E Spinner if segment number 0 CALLS None CALLED BY Under user program control NOTES Destroys All 52 MISCELLANEOUS 53 BOOT UP ADDRESS 0000 INPUT None FUNCTION S Set stack 073B9h Continue the execution by calling POWER UP OUTPUTS None CALLS POWER UP CALLED BY RESET or POWER ON NOTES None 54 RAND GEN ADDRESS INPUT None FUNCTION S Set
137. d push pop pop 2 REPEAT RPT 2 push push kCkckckckckckckck ck ck kk ok constitute the background in which an object is to be moved at X PAT POS Y PAT POS HL Location in CPU RAM to which the names are moved E X PAT POS Left hand column D Y POS Top row of pattern Y EXTENT and X EXTENT of pattern ee CALC OFFSET Offset into name table of position of bc upper left hand pattern b 000H Get X EXTENT into IY bc 7 number of names per row iy bc EXTENT 1 times bc de 108 push hl push iy 1 a 002H Table code for pattern name tabl call VRAM pop iy pop hl pop de pop bc push bc id b 000H BC X EXTENT add hl bc Point HL to beginning of next row ld bc 00020H ex de hl add hl bc Increment offset by 32 ex de hl pop bc dec b 4 UNTIL B EQ 0 jr nz RPT 2 ret H kkxkxkxkxkxkxkxkxkxkk kxxkx k CALC OFFSET KEK KKK KEK KKK KKK KKK KK KKK KKK KKK KKK KKK KKK KKK KK KKK ko kockok Description This routine calculates the proper offset into the name table for the pattern position given by X PAT POS Y PAT POS formula used is offset 32 Y PAT POS X PAT POS Input D E Y PAT POS X PAT POS Output DE Offset Ck ck Ck ck ck Ck ck kk Ck CK Ck Ck ck Ck Sk Ck Ck Ck ck Ck ck Ck Ck Ck Sk Ck ck Ck kk Ck
138. dd de hl pop bc ret ACT MOBILE SUBCASE Mobile call INIT XP OS X PAT POS 80H Insert new generator address in object CPU RAM inc de ld a de 97 ld inc ld ld pop ret ACT OSPRT 1 005 1 006 af SUBCASE Sprite size 0 ACT lSPRT 51 SUBCASE Sprite size 1 inc inc inc inc inc bc bc bc bc de hl hl a 11 e a 000H de hl e 51 hl d 11 hl a 11 bc a 11 b 000H bc iy de hl de af nc a 001H PUT Init 2NEXT GEN in status G EW EN in CPU RAM 7 HL gt FIRST GEN NAM xl SV index to VRAM DE PTRN PTR CALC amp SI HL gt SO URCE PTRN GEN ET NEXT GEN CPU RAM DE INDEX TO PTRN GEN VRAM Signal sprite PRTN gen fill 98 PUT DEFRD PUT OBJ kk ck k kk PUTOBJ Ck ck Ck Ck Ck Ck Ck Ck CK Ck Sk Ck ck CK Ck kk Ck ck ck kk kk ck kk ck Sk Sk Pk kv kv ko ko ko DESCRIPTION Putobj vectors to one of 5 specific routines for placing the different object types on the display INPUT IX B Address of object to be processed Parameter to be passed specific put routines In addition this module contains routines which allow VRAM operations to be defered typic
139. dress of object s graphics tables in ROM kc ee koe he ke check ke e ke ke ke he ke ke e he ke khe he ke he he ke e he ke ke she he ke echec ke ke he ke ke he heck e he ke e he ke ke che he ke e ke ke ke ke PUTSEMI d 1 003 e 1 002 GRAPHICS n IX ld add add id add inc to see ld bit jr call ret S OLD SCRN push push push jr jr IF 000H hl de hl de 005 hl de e 51 hl d 11 de hl bc de 11 hl b hl hl if OLD SCR i d 1 002 e 1 001 PX TO PTRN c e d 1 004 e 1 003 PX TO PTRN _ 1 000 1 I POS POS a 7 2 bc de hl 070H z EQUAL TO c ELSE 1 A GE 70H 1 005 OLD SCRN PX TO PTRN POS OBJ n IY C B PUT FRAME GET BKGRND Get address of status And put it into IY Get X LOCATION Pattern plane col Get Y LOCATION Pattern plane row Get frame number STATUS n C COL B ROW E FRAM I GI DE has frame number 2 Frame number Addr of graphics n Frame pointer offset ENT EXTI ENT HL now points to location holding address of frame Get address into DE Address of frame Y PAT POS amp X PAT POS HL points to 156 name in list EN
140. e jp hl do 1 pass thru effect RET from effect else process a non effect note L10 call ATN SWEEP atn sweep data if any call FREQ SWEEP sweep data if amp note dura timers if psw is zero note is over jr nz L12 EFXOVER ld a ix 000H SONGNO this note 84 L12 push call pop ld if J call ret af LOAD NEXT NOTI bc a ix 000H b psw is nzero Z2 UP CH DATA PTRS rdi on stack load data for next note CH SONGNO previous note SONGNO new note may be inactive check against new note s CH SONGNO change to from tone efx noise to maintain data area priority system 85 PLAY SONG IDENT PLAYSON includes TONE OUT ko kc ke PLAY SONGS pOCKCKCkCk ck kckckckckckckckckckckckckckck ke ke ke kk COMMENT j Users SFX refers i Manual for description to the beginning address of a special sound effect routine Globals GLB PLAY SONGS TONE OUT Externals EXT UPATNCTRL UPFREQ INCLUDE OSSR_EQU 0S 0 equates Defines OFF EQU SRIATN EQU 090H SR2ATN EQU OBOH SR3ATN EQU ODOH SRNATN EQU OFOH SRIFRQ EQU 080H SR2FRQ EQU SR3FRQ EQU OCOH SRNCTL EQU OEOH SOUND PORT EQU OFFH PLAY SONGS
141. e 0 FB NFI NFO Length of note Step size Number of volume step Step length 1 volume step length For the special meaning of FB NF1 and NFO read section SOUND GENERATOR page 188 SPECIAL EFFECT 7 6 5 4 3 2 1 0 Channel 0 0 0 1 0 0 Address of the special effect sub routine in 2 bytes of course END OR REPEAT 7 6 5 4 3 2 1 0 Channel 0 1 Repeat 0 0 0 191 SOUND TABLES Based on The Hackers Guide to and The Absolute OS 7 Listing SONG DATA AREAS IN RAM With SOUND INIT the user initialize the song data areas in the cpu RAM These song data areas are 10 bytes long and formated like this 7 6 5 4 3 2 1 0 Channel Song number Address next note 8 lower bits Address next note 8 higher bits Frequency 8 lower bits Volume in 4 bits 0 0 Frequency 2 hi bits Length Frequency step length 1 frequency step length Frequency step size Volume step Number of volume step Volume step length 1 volume step length Right after the last song data area a special END 00h code indicates the end of the song data areas It s the resposability of the user to allocate enough free RAM space for the song data areas SONG TABLE IN ROM A song table consists of a number of entries Each entry is composed into two addresses The first address is a pointer to the song data in ROM encoded into the OS 7 sound data format The second address i
142. e most essential information Section I BEFORE PROGRAMMING shows an overview of all the necessary informations to know before programming a real ColecoVision game Section II OS 7 ROUTINES SPECIFICATIONS covers all the functions of the ColecoVision BIOS with necessary information to properly use them Section III OS 7 ABSOLUTE LISTING supplies listing for the ColecoVision BIOS code Section IV APPENDIX contains suplement of information about the ColecoVision itself TABLE OF CONTENTS ACKNOWLEDGEMENTS 5 entier btt tdi per tee eee cdseaerssaels O 1 PREEAGCB tere eter etre e e vtae ii TABLE OE CONTENT S ner et pe ee pei te gne EEEN E NA NOE O AE iii BEFORE PROGRAMMINQG sees eS AAEE ANA Eaa 1 Defined Reference Locations us seeded ete ire 1 B tope America Bytes as ec eere ere et enne ee desee 1 Graphics Tables Bek RU eta 1 Cartridge ete ie ene tet s 1 RAY AE A dehet 2 Dealing with OS Bugs ere etuer vates teo en eet veterea edes 2 WRITE VRAM AND READ 2 SEMI MOBILE OBJECT IN GRAPHIC MODE 1 sese nnns 2 PATCH trier erret
143. eader A CHE 000000 new SONGNO Store back in byte 0 ETed with address byte offset IY byte 0 and DE offset IY byte 0 offset DE Addr of destination byte in SxDATA 91 ACTIVATE IDENT ACTIVATI ZOP EPOP COMMENT Fl ACTIVATE Ck Ck Ck Ck Ck Ck Ck Ck Ck Ck Ck kk Sk kk Sk Sk Sk ke kx kv kx ko ko E 4 22 82 13 50 00 The following changes revisions were made Init X PAT Add code to PK rn Use CONTROL Eliminate code placing OLD SCREEN address in status area POS in OLD SCREEN when in VRAM as well as when in CPU RAM x Use VDP MODE WORD to test graphics mode expand one color generator byte to 8 Added C BUFF defs 8 for color expanding code Fix color gen move in mode 1 5 02 ER MAP for buffer area ACTIVATE is used to initialize the RAM status area for the passed object and move its pattern and color generators to the PATTERN and COLOR generator tables in VRAM The second function is enabled or disabled by setting or resetting the carry flag in the PSW this is necessary to prevent sending the same graphics data to VRAM more than once when creating identical objects The calling sequence for activating an object is as follows LD HL OBJ n 20BJ to activate S
144. er Base address Timer offset already available Setup offset to subsequent timers See if the first timer is requested If so we have a match Otherwise Loop to find requested signal Check if end of table If so go no further If not then offset to next timer Decrement signal request 133 pj ct jr nz FREEL hen go try the next lse E MATCH m c K N atches current signal bit FREE 1 jr nz FREE SET set FREE hl bit REPEAT hl jr z FREE SET bit LONG hl jr z FREE SET all FREE COUNTER REE DELETE COUNTER ENL 3 82 EEDS FREE COUNTER inc hl ld e 1 inc hl ld d h1 push de ld hl TIMER TABLE BASI push hl NEXT bit EOT 1 jr nz MOVE IT bit FREE 1 2 1 1 048H cp 048H JE nz GET NEXT inc hl inc hl ld a hl cp d jr c GET NEXT jr nz SUBSTRACT 4 dec hl ld a hl cp e jr c GET NEXT jr z FREE EXIT inc hl SUBSTRACT 4 ld d 1 dec hl ld e h1 dec de dec de dec de dec de id hl e inc hl ld hl d jr GET NEXT GET NEXT pop hl TO DELETE counter addr If requested signal not zero Here when the requested signal
145. es of the sprite are in terms of pixels the sprite can be positioned and moved about very accurately Sprites are available in three sizes 8x8 pixels 16x16 pixels and 32x32 pixels The sprites are showed in Multicolor and Graphics modes only There is also a restriction on the number of sprites on a line only 4 sprites can be active on any horizontal line the additional sprites will be automatically made transparent Behind the sprite planes is the pattern plane The pattern plane is used for textual and graphics images generated by the different screen modes The pattern plane is broken into group of pixels called pattern positions Since the full image is 256x192 pixels there are 32x24 pattern positions of 8x8 pixels on the screen in the Graphics modes 40x24 positions of 6x8 pixels on the screen in the Text mode and 64x48 positions of 4x4 pixels on the screen in the Multicolor mode Behind the pattern plane is the backdrop which is larger in area than the other planes so that it forms a border around the other planes The backdrop consists of a single color used for the display borders and as the default color for the active display area The default color is stored in the VDP register 7 When the backdrop color is transparent the backdrop automatically defaults to black BACKDROP TV SCREEN 31 0 SPRITES 198 VDP Screen modes
146. et false otherwise CALLS None CALLED BY Under user program control NOTES Destroys BC and HL 46 CONTROLLER ROUTINES 47 CONTROLLER INIT INPUT None FUNCTION S Initialize controller to strobe reset Clear controller memory and debounce status buffer Clear remaining variables SWO CT 7 Spinner counter port 1 SWI CT 73 Spinner counter port 2 50 CO 73EB Segment 0 data port 1 50 CI 73EF Segment 0 data port 2 51 CO 73 0 Segment 1 data port 1 51 CI 73F1 Segment 1 data port 2 OUTPUTS None CALLS None CALLED BY POWER UP NOTES CONTROLLER MAP 8008 DBNCE BUFF 73D7 73D8 are needed A B IX IY are affected 48 CONT READ INPUT 0 for player 1 1 for player 2 FUNCTION S Return the complement value of the controller port H segment 0 data joystick data OUTPUTS A Raw data from controller H CALLS None CALLED BY DECODER NOTES Because the returned value in register A 15 the complement of the controller port data bits 1 mean data bits 0 mean no data Only register A is affected 49 CONTROLLER SCAN ADDRESS 1F76 INPUT None FUNCTION S Update SO CO 80 51 SI CI by reading segment 0 and 1 from both controller ports OUTPUT None CALLS None CALLED BY POLLER or under user program control NOTES Because the returned value in register A is the complement of the
147. f OBJ hl Save pntr to frame list de Save pntr to offset list 1 1 004 h ix 005H HL Addr of component OBJ ix Point to next object pointer ix hl hl HL points to status pointer e 51 hl d hl DE Addr of status for component object de iy IY Addr of status for component object de DE pntr to offset list hl HL pntr to frame list a hl Get frame number 7 iy 000H Preserve bit 7 of frame z TBLO used by mobile objects to indicate which VRAM tables in use 7 a iy 000H a Move to components status area hl Point to next frame number a de Get X Offset l a h 000H X Offset hl bc HL X Offset X Location iy 001H 1 iy 002H h Component s X Location X Offset de Point to Y Offset 129 ld ld add 1 Y Location exx inc djnz Call PUT pop ld add pop LP2 ld ld inc inc pointer push pop push push ld call pop pop dec jr ret a de l a h 000H hl de iy 003H iy 004H Dp de 1 iy bc 00004H iy bc de 1 iy 000H h iy 001H iy iy hl ix iy de b e PUTOBJ de iy d nz LP2 HL Y Offset HL Y Offset Y Location Component s Y Location Y Offset Point to next offset pair ECT for each of the component objects pass selector in B Get object address back IY points to pointer to lst component object DE Counter a
148. f song 1 data area S1DATA id b 001H IX to byte 0 song data area for song 1 call PT IX TO SxDATA LOOP until end of song data areas 11 ENDSDATA check for end of song data areas cp ix 000H set Z flag if negative ret 2 leave Z set if all data areas have been processed process active song data areas call PROCESS DATA AREA update counters of call effect get next note E point IX to byte 0 next song data area ld 00AH 1 000 add ix de jr 11 repeat loop kc ko ke ko koe e ke ke ke ke KK UP CH DATA PTRS ke koe ke kc ke kc ke ke o ko e COMMENT j For each active data area starting with S1DATA and proceeding in order load the associated channel data area pointer PTR TO S ON x with the address of byte 0 This routine is called by JUKE BOX when a song starts and PROCESS DATA AREA when the channel using a data area has changed as a result calling LOAD NEXT NOTE this happens when a song finishes and when it switches back and forth between noise and tone notes i UP CH DATA PTRS push ix curent id hl DUMAREA all 4 ch data ptrs to dummy inactive area ld TO S ON 0 hl ld PTR TO S ON 1 hl ld PTR TO S ON 2 hl ld PTR TO S ON 3 hl ld b 001H 83 DONE call PT IX TO SxDATA LOOP until end of song data areas ld a ix 000H cp ENDSDATA
149. frame is positioned at X PAT POS Y PAT POS Input HL Addr of list of names in CPU RAM D E Y PAT POS X PAT POS Y EXTENT X EXTENT kk cc ck ck ck c ck kk ck ck kk kc kk ck ck kk ck ck ck kk Sk ck ck PUT FRAME push bc Copy parameters into primed registers push de push hl And frame address into DE exx pop hl pop de pop bc call CALC OFFSET exx Test for the following condition X POS sle 32 and X POS X EXTENT sgt 0 1 1 a e 15 X POS lt 0 bit 7 a jr nz XP NEG cp 020H Is X PAT POS 32 ret nc If not return XP NEG add a c X POS X EXTENT 106 bit ret ret X IN BOUNDS 7 bit jr ld add push TE ld LT33 ld ld push pop pop ld exx push neg ld ld add ex add ex pop exx jr ELSE PF2 ELSE pus ld pus pop pop END IF 9 END IF 8 ld 7 nz 1S MINUS LSE 8 a 020H b 000H hl bc de hl hl bc de hl bc END IF 9 a e ac 01 z ELSI ELS a 020 un ow d 000H iy de END IF 9 bc b 000H bc iy bc 000H IF x PAT POS O Then Substract X PAT POS from 31 2 Is zer Is Yes A Yes EXTI A Neg return 0 return
150. ge programs can make mode dependent decisions about the sprite size or VRA table arrangement This word is maintained by the WRITE REGISTER routine whenever the contents of registers 0 or 1 are changed IMPORTANT NOTE TT IS THE RESPONSIBILITY OF THE CARTRIDGE PROGRAMMER TO MAKE KERE SURE THAT NON STANDARD USE OF AUN E THE VDP REGISTERS DOES NOT MAKE THE DATA IN THIS WORD INVALID AARE VDP STATUS BYTE EQU 073c5H The default handler for the NMI which must read the VDP status register to clear the interrupt condition places its contents 71 here This byte is the most accurate representation of the actual VDP status that is available to the cartridge programmer provided that the VDP interrupt is enabled on chip EFER WRITES EQU 073C6H This is a boolean flag which is set to FALSE at power up time should be set to true only if the cartridge programmer wishes to defer writes to VRAM If this flag is true then the writer routine must be called regularly to perform defered writes MUX SPRITES EQU 073C7H This boolean flag with default FALSE value should be set to TRU the cartridge programmer wishes one level of indirection to be inserted into sprite processing by having all sprites written to a local SPRITE NAME TABLE before being written to VRAM This aids
151. h push ld call pop pop pop pop pop push push push push CLR af bc iy de hl a 003H PUT VRAM hl de iy bc af af bc iy de SAVE FOR RESTORE Signal PTRN gen fill Restore Save for retor 96 push bit J add ld call ET pop pop pop pop pop ret o UJ W hl 4 a How many color gen bytes nz ONE BYTE hl bc HL Color gen source a 004H Signal PTRN color fill PUT VRAM ra hl de iy bc af For each item to send duplicate the color byte 8 times in C BUFF then send this generator to VRAM color table indexed by DE E ONE BYTE ad hl bc HL Color byte ld b h BC Color byte push iy pop hl Item count NEXT COLOR push hl Save counter id a bc Get color byte push bc Save pointer to color id bc 00008H Create 8 duplicates id hl WORK BUFFER add Place then here starting at end of buffer id b 008H DUPLI dec hl ld hl a djnz DUPLI push de Save index into tables ld iy 00001H 21 item to send ld 004H Color table code call VRAM pop de Get index back pop bc Pointer to color byte inc de Increment index inc bc Increment color pointer pop hl Get item counter dec hl id a h 1 jr nz NEXT COLOR jr O B RET Internal to update to next VRAM index screen area SUP UPDATE push bc ld bc 00100H ex de hl a
152. h seventy one 71 bytes at the high end of memory are used by various OS routines The top of the stack 15 sitting at address 73B9h which grows in the decrementing direction Between stack and user buffer there are 942 bytes available for the application program However care should be exercised in both size and boundary when using RAM as scratch pad Special note the stack pointer address 15 set by the OS before running the game and it s a good practice to never set yourself the stack pointer specially if the game uses the OS functions Of course if the game don t use the OS sound routines the reserved locations 7020h 702Ah can be used for any purpose Dealing with OS Bugs WRITE VRAM AND READ VRAM It works as advertised for byte counts less than 256 00h FFh and for byte counts that are multiples of 256 100h 200 For other values it substracts 256 1001 from the actual byte count Programmers should deal with this problem by always sending numbers of bytes that are less than or even multiples of 256 100h They should not deal with it by padding their byte counts as this may lead to cartridges that fail when the bug is fixed Note PUT VRAM and GET VRAM call these routines so take care SEMI MOBILE OBJECT IN GRAPHIC MODE 1 In the graphic mode 1 ACTIVATE writes the pattern generators for a semi mobile object to VRAM properly but miscalculates the number and placement in VRAM of the corresponding color bytes when operating
153. he attenuator values along with their bit position in the data word are shown below Multiple attenuation control bits may be true simultaneously Thus the maximum attenuation is 28 db A3 A2 A1 0 Weight 0 0 0 1 2 db 0 0 1 0 4 db 0 1 0 0 8 db 1 0 0 0 16 db 1 1 1 1 OFF Remark Louder is the note lower is the attenuation value SOUND CONTROL DATA FORMATS This is the data formats to be send directly to the sound port Offh Frequency 1 Reg Addr Data 0 X Data 1 RO 0 F3 F2 Fl FO F9 F8 F7 F6 F5 F4 Noise Control Reg Addr Shift 1 1 1 0 NFO Attenuator 1 Reg Addr Data 1 RO 1 A2 Al AO SOUND CONTROL NUMBERS TABLE Pitch Volume First byte Second byte High Off Voice 1 80 8F 00 3F 90 9F Voice 2 AO AF 00 3F BO BF Voice 3 CO CF 00 3F DO DF 0 E3 Voice 3 Periodic buzz Noise E4 E7 7 Voice 3 White shhh FO FF Off Attenuation 189 SOUND DATA FORMAT From the Hackers Guide to ADAM The following information is the sound data format to be used in the songs encoded in coleco games Channel 2 bit values 00 Noise 01 Tone 1 Generator 10 Tone 2 Generator 11 Tone 3 Generator A noisy sound needs a specific sound data format Numbers 7 to 0 indicate bits position
154. hen must be state 1 Else state 0 Get current data If old new Then saw data twice in sequence Else first time save current data Set state 1 Save in controller memory 2fire Get current data If old new No change in state Else save current data Set state 0 Controller memory pointer Debounce status buffer Mask out valid data and save it Get old data and current status If state lt gt 0 Then must be state 1 Else state 0 Get current data If old new Then saw data twice in sequence Else first time save current data Set state 1 Save in controller memory 2joy Get current data If old new No change in state Else save current data Set state 0 145 JOY 1 ret ARM button Input A IX IY ARM DBNCE ARM REG ARM ARM push push and Q 5 1 puo 1 07 STAT Fl w de bc debounce routine Raw data Controller memory pointer Debounce status buffer be de ARM MASK e a b iytARM OLD 1 STATI 000H nz ARM 5 1 Fl a e b z ARM REG iy ARM_OLD e ARM EXIT a 001H 1y ARM STATE a ixtARM e ARM EXIT Mask out valid data and save it Get old data and current status If state lt gt 0 Then must be state 1
155. is passed in DE COUNT is passed in BC DESTROYS ALL VRAM READ P dw 00003H dw OFFFEH ter to data buffer VAR DATA BUFFER DEST INTEGER COUNT INTEGER HL EADO VAR DATA BUFFER SRCE INTEGER COUNT INTEG is passed in HL 166 pop id ld INPUT LOOP ini nop nop jp dec jp jr END INPUT ret REG READ in ret 00002H 00002H bc VRAM READ P de AREA _ hl PARAM AR de PARAM AR bc PARAM AR Ls E gt a e CTRL PORT a a d CTRL PORT a bc de c DATA PORT b e nz INPUT LOOP d m END INPUT nz INPUT LOOP a OBFH 167 GRAPHICS PRIM PKG This is a package of routines that allow applications programmers to operate on shape generators Each of them takes as inputs in one of the generator tables in which the generators to be operated upon reside a count of the generators to be used and an area of the same table into which the results are to be put The only RAM area they is in the WORK BUFFER a pointer to which is declared as an external and defined in the cartridge ACkckckck kck ck kk NOTE THESE ROUTINES WRITE TO AND READ ERRE WITHOUT POSSIBILITY OF DEFERAL AND SHOULD NOT BE USED IN ANY
156. is zero note is a special effect jr nz L15 CASE special effect EFFECT pop iy SONGNO push iy put SONGNO back on stack push bc header on stack NEXT NOTE PTR SFX DE SFX inc hl pt HL to next byte LSB addr SFX id hl E LSB SFX ld ix 001H e put LSB of SFX in byte 1 of SxDATA NEXT NOTE PTR inc hl pt HL to NSB SFX 1 d hl D NSB SFX ix 002H d put NSB SFX in byte 2 of SxDATA inc hl point HL to next not after this new note push iy SONGNO af push de 551 on the stack pop iy 1 de PASS1 create CALL IY with RET to 551 by storing push de PASS1 on stack jp iy lst 7 bytes SFX will save addr next note amp SONGNO PASSI ld 000H in same fashion create CALL IY 7 ld e 007H to allow SFX to load initial values add iy de ld de MODBO RET to MODBO push de jp iy INFO index jump if here note is type 0 3 115 push bc save header on stack ld a b A fresh copy header and 003H mask all but type number cp 000H test for type 0 psw is zero note is type 0 fixed freq and atn nz L16 E CASE note type 0 set up NEXT NOTE PTR TYPEO inc hl next note after this new note is 4 bytes away 89 117 TYPE2 Since it s L18 move inc hl point HL to it inc hl inc hl id ix 001H 1 put addr in NEXT NOTE P
157. jr nz L18 dec hl So move HL back 1 byte ld ix 001H 1 put addr in NEXT NOTE PTR 1 ix 002H h new note data and fill in bytes where necessary dec hl point HL back to 1st ROM data to move APS ld 009 point DE to destination bytes 9 8 5 3 call DE TO DEST id bc 00002H move 2 bytes 90 NLEN TYPE3 b 03EH MODBO 008H 000 hl de ix 001H 1 ix 002H h new note data and fill hl lx iy 009H iy de iy de bc 00007H ix hl af bc OFFH Z d a 004H nz L20 LOAD NEX a d b hl a offset from byte 0 ix iy iy de iy de when done DE points to FSTEP HL to ROM FSTI pt EP 0 for no freq sweep DE to RAM NLEN move last 3 ROM bytes if this is a noise note garbage will be loaded into byte 3 buts that s OK note after this note is 8 bytes away pt HL to it put addr in NEXT NOTE PTR in bytes where necessary Point HL back to 1st ROM data to move Point DE to destination bytes 9 3 IY Addr byte 0 and DE 6 DE 9 IY byte 9 APS APS DE addr APS move 7 bytes pt HL to byte 0 A Header new not SONGNO Test for inactive song over as detected Save header in D Rid channel bits Special effect Restore A to h
158. ko ko ko ko ko ko ko ko KK This listing has the actual address of the start of OS routines E Rev History one line note indicating the change Date Change H 4 14feb1983 Filler locations changed to OFFH to reflect OS 7PRIME Prom release date changed to December 28 1982 from May 1982 change to OS 7PRIME to reflect majority of versions in the field at this date 3 24nov1982 Timing change to shorten LOGO delay x Title changes to JMPTABLES and OSSR EQU 2 60ct1982 Minor comment modifications 1 23sept1982 OS 7 as one absolute file 0 may 1982 OS 7 listing by module EXPORTS ENTRY POINTS TO OS ROUTINES GLB INIT TABLE TABLE MANAGER GLB GLB GLB INIT SPR ORDER GLB SPR NM TBL GLB INIT_TABLEP PASCAL CALLS GLB VRAMP 63 Q AARAA QAAQAAQAQA LB PUT VRAMP LB INIT SPR ORDERP LB WR SPR NM TBLP LB WRITE REGISTER VIDEO DRIVERS READ REGISTER LB WRIT
159. lor table offset no more used in VRAM routines Copy of COUNT for PUT VRAM amp GET VRAM 184 OS 7 AND EOS SIMILARITIES Based The Hackers Guide to and The Absolute OS 7 Listing List of OS 7 symbols calls amp variables similar to the EOS ones For ColecoVision ADAM programmers EOS 05 7 SYMBOL LFDF WRITE VRAM FD1D 1FE2 READ VRAM FD20 1FD9 WRITE REGISTER FD23 LFDC READ REGISTER FD26 F82 FILL VRAM FD29 LFB8 INIT TABLE FD2C FBE PUT VRAM FD2F GET VRAM FD32 08 0 CALC OFFSET FD35 07 8 PX PTRN POS FD38 LOAD ASCII FD3B 1 4 WR SPR TBL FD3E 1F76 CONTROLLER SCAN FD41 1F88 UPDATE SPINNER FD44 0190 DECLS FD47 019B DECMS FD4A 01A6 MSNTOLSN FD4D 01B1 ADD816 FD50 1 SOUND INIT FD53 1 6 TURN OFF SOUND FD56 1 59 1 61 1 4 PLAY SONGS SOUND MAN FD5C 01D5 02 LEAVE EFFECT or EFXOVER FD61 FD62 73C3 73C4 VDP MODE WORD FD63 7305 STATUS MODE BYTE FD64 FD65 73F2 73F3 SPRITENAMETBL FD66 FD67 73 4 73 5 SPRITEGENTBL FD68 FD69 73F6 73F7 PATTRNNAMETBL FD6A FD6B 73F8 73F9 PATTRNGENTBL FD6C FD6D 73FA 73FB COLORTABLE FE58 73EB SPIN SWO FE59 73EC SPIN 1 FE5A FE65 2222 22
160. ment bit EOT hl End of table jr nz SCRAM If it is we re done inc hl Otherwise get next timer inc hl and start over inc hl jr NEXT TIMERO SCRAM ret DCR TIMER push hl Save current timer bit LONG hl Long jr z DCR S MODE TBL Short non repeating bit REPEAT hl Repeat jr nz DCR L RPT TBL Long repeating 131 DCR L MODE TBL inc DCR L RPT TBL inc ld inc id pop DCR S MODE TBL inc dec jr pop push push bit jr inc inc 1 dec push ET DON set TIM ER pop ret E BIT EXIT SAVE 2 BYT ld Long non repeating he counter to DI Decrement Check if 0 If not save m Otherwise get mode byt and set it s done bit Long repeating timer GI he counter to DI Exchange and ddr Into DE Decrement Check for 0 Save if not Otherwise reload al counter jockey all over to perform said task et done bit Repeat If not leave Otherwise jockey around again and reload original hl e hl Move t hl d 11 de a e d nz SAVE 2 BYTES hl hl SET DONE BIT hl e hl Move t hl d 11 de hl P e hl load a hl d h1 de a e d nz SAVE 2 BYTES 5 nt e hl origin hl d 11
161. n 203 CHARACTER PATTERN SAMPLE tet eet ee rq ee A e e Rn 203 Screen Mode 0 Character Sample crinca niota e E E E E ENER 203 Screen Mode Character Sample ree TORRENS RUNE ed 203 Screen Mode 2 Character Sample e eO e re E ERU RE 203 eii A 204 GDOSSARY cete ted tte ne EO SERE ERG PR E ERRARE ARS BA 206 viii BEFORE PROGRAMMING Source ColecoVision Programmers Manual The following text shows what to know before programming a real ColecoVision game Defined Reference Locations In the OS ROM area it s IMPORTANT to know that the application programs games should only use the OS entry points and global symbols listed in the appendix Accessing to the OS otherwise is illegal and may cause program malfunction when hardware configuration changes or OS routines relocated due to update This warning still important today to keep the compatibility of the games with the actual and future ColecoVision clones Europe America Byte The European TV uses PAL system 625 line format which requires interrupt at the end of each active display scan every 1 50 second as opposed to every 1 60 second for the American model NTSC 525 line format ColecoVision cartridges must be interchangeable between both systems If a real time display such as a clock must be implemented the program will have to access
162. nd Selector HL Address of component object IY Points to next component object IX Address of component object Save pointer Save counter and selector Selector Get counter and selector Get address of next component object pointer 130 TIME MANAGER Ken Lagace and Rob Jepson 3 82 Global GLB TIMER TABLE BASE Is this necessary GLB NEXT TIMER DATA BYTE Or this Extern EXT PARAM Parameter passing routine needed for setting up pascal interfaces Global GLB INIT TIMER GLB INIT TIMER GLB FREE SIGNAL GLB FREE SIGNALQ GLB REQUEST SIGNAL 7 REQUEST SIGNALO GLB TEST SIGNAL GLB TEST SIGNALQ GLB TIME MGR_ 7 GLB TIME MGRQ Define DONE EQU 7 REPEAT EQU 6 FREE EQU 5 4 3 EOT EQU EQU x wo X vw o MODE TO CHECK BIT BIT JR Z JUMP IF BIT IS 0 DONE REPEAT FREE BOOT 5 LONG 7 6 5 4 77 3 2 1 r 0 TIME MGRO TIME MGR ld hl TIMER TABLE BASE Current time address NEXT TIMERO bit FREE hl Free call 7 TIMER If not decre
163. ne CALLED BY Under user program control NOTES DE and HL are affected 42 INIT TIMER ADDRESS 7 INPUT HL base address in CPU RAM for timer table DE base address in CPU RAM for data block FUNCTION S Store given base address for timer table in TIMER TABLE BASE 7303 7304 and for data block in NEXT TIMER DATA BYTE 73D5 73D6 OUTPUTS None CALLS None CALLED BY Under user program control NOTES DE and HL are switched 43 FREE SIGNAL ADDRESS IFCA INPUT A signal timer number to be freed 0 1 signal 1 2 signal etc FUNCTION S Finds signal timer A stops it by setting bit 5 FREE and release its data block if exists OUTPUTS None CALLS None CALLED BY Under user program control NOTES 44 REQUEST SIGNAL ADDRESS INPUT HL length of timer A repeating timer if 0 non repeating type 1f not FUNCTION S Search for a free signal timer and initialize it with HL and Return signal timer number used in A OUTPUTS A signal timer number CALLS None CALLED BY Under user program control NOTES 45 TEST SIGNAL ADDRESS IFDO INPUT A signal timer number to be tested FUNCTION S Check if the signal timer number exists If so return A true if bit 7 DONE is set and free up the signal timer if non repeating counter Otherwise return A false OUTPUTS A true if signal bit 7 DONE is s
164. nes are complex slow need too much RAM space 25 ACTIVATE ADDRESS 1 7 INPUT HL pointer to the object data Carry flag is set to move graphic data to VRAM reset otherwise FUNCTION S Initialize the RAM status area for the passed object If carry flag is set move object pattern and color generators to the PATTERN and COLOR generator tables in VRAM OUTPUTS None CALLS local name for PUT VRAM VRAM local name for WRITE CALLED BY Under user program control NOTES VDP MODE WORD 73C3 WORK BUFFER 8006 may be needed by called subroutines AF HL DE BC and IY are affected Additional may be changed by called subroutines OBJECT HEADER pointer to OBJ GEN CPU ROM pointer to OBJ CPU RAM The OBJ GEN CPU ROM header starts with less significant nibble LSN as OBJ TYPE OBJ TYPE 0 semi mobile 1 mobile 2 Osprite 3 1sprite other complex BUG Error in subroutine for semi mobile type objects in graphic mode I 26 SET UP WRITE INPUT IX data pointer B parameter FUNCTION S Sets up defered VRAM operation OUTPUTS None CALLS None CALLED BY PUTOBJ NOTES Destroys all 27 INIT WRITER ADDRESS 1 5 INPUT A size of the defered write queue HL location in RAM of the defered write queue FUNCTION S Initialize defered write queue in RAM QUEUE SIZE 73CA A QUEUE HEAD 73CB 0 QUEUE 73
165. ns STATUS REGISTER ite nr t Retenir anat tto e he RR ER ERES VDP REGISTER ACCESS VRAM MEMORY ACCESS DELAY 196 NMI Non Maskable Interrupt esses ie EE i nennen rne nennen eene nennen 196 COLOR neither RO Re e Ee ee ee 197 VIDEO DISPLAY SUMMARY tette eco Re e RR ER eee 198 VDP Screen modes tie peteret ab aug e e up ret eret a cei 199 Mode Graphies se err tee o eerte de eet Aerei ete E DES 199 Mode i ted e tee ate a cep 199 Graphics D e eer eie ereptum eel e ENS 199 Mode 3 Multicolor 5 4 st ea eee QU ge a etate eate 199 SPRIIES 4 ren Y e ds ee 200 SPRITES 45 TA tto 200 SPRITES LOCATIONS ON SCREEN airan as aea Sra enne 200 SPRITES PATTERN veces aee erp e RO ED RR ee e een 200 tutes es 200 16 16 5 edes n b fite lea n o e 200 SPRITE Sx8 SAMPLE eet e tue ter i end e e rre n EUR Ms 201 SPRITE 16x16 SAMPLE ert rr de sene e le ete ins fermer deti ee Pee PR 201 CHARACTERS d tit ee ete iet 202 VIDEO MEMORY FOR CHARACTERS sese nete netten retener nnne 202 CHARACTER PATTERN ettet rtr P RE E ette tt PR Dei Reite
166. nt hl 1 hl hl e hl hl SET DONE BIT Then s hl hl nz TIMER EXIT hl hl REPEAT hl z SET DONE nt nt a hl hl 1 hl hl hl DONE hl hl 1 132 hl hl e TIMER EXIT dec 1 jr Timer of Timer Procedure Init HL has address DE has address P Common INIT TIME DATA DEFS 2 2 DEFS 2 E E INIT TIMER PARAM dw 00002H dw 00002H dw 00002H INIT TIMERQ table of Timer Data Table bc INIT TIMER PARAM ld de PARAM AREA call PARAM hl PARAM AREA id de PARAM AREA 2 INIT TIMER ld TIMER TABLE BASE hl Store given base address 4 for timer table ld h1 030H Set first byte in timer table to free and last timer ex de hl ld NEXT TIMER DATA BYTE hl Store given base address for data block ret Procedure Free Signal Acc has signal number to be freed No output is generated Common SIGNAL NUM DEFS 1 FREE SIG PARAM dw 00001H dw 00001H FREE SIGNALQ ld bc FREE SIG PARAM id de PARAM AREA 4 call PARAM _ ld a PARAM AREA 4 FREE_SIGNAL_ ld 1 hl TIMER TABLE BASE ld b a ld de 00003H or a jr z FREE MATCH 1 bit EOT hl jr nz FREE EXIT add hl de dec Put Free code into register Get Tim
167. oe SITUATION WHERE THEY MAY BE Ckckckck kck ck kck kk INTERRUPTED Define TRUE EQU 1 FALSE EQU 0 PATTERN GEN EQU 3 COLOR TABLE EQU 4 H External EXT WORK BUFFER Global GLB RFLCT VERT RFLCT HOR ROT 90 ENLRG PROCEDURE REFLECT VERTICAL TABLE CODE A SOURC T I hc If the generators are from the pattern plane and the graphics mode is 2 the routine also copies the corresponding color generators assumes that the color data has already been set up BEGIN REFLECT VERTICAL RFLCT VERT ld ix RLFCT VERT jr CONTINUE GRAPHICS PROCEDURE REFLECT HORIZONTAL TABLE CODE SOURCI zJ T It reflects each of a block of generators from VRAM around the horizontal Ckckckck ck ck ck kckck 3 Ckckckck ck ck ck kc kk Ckck ck Ckck ck ck ck kck ck kk k Ckckckck ck ck ck kc kck Ckckckck ck ckck kk ck 3 Dk CK ck ck Ck ck ck Ck Ck Ck Ck Ck Ck ck Ck ck Ck ck kk Ck kk Ck Sk ck Ck Sk ck kk Ck kk kk Sk kk Ck kk Sk kk kk Sk kk kk ko kk kc ko ko ko DE DESTINATION HL COUNT BC DE DESTINATION HL COUNT BC an area otherwise is reflects each of a block of generators from VRAM around the vertical axis then axis If the generators are from the pattern plane and the gr
168. of bit operations on RAND NUM to calculate next pseudo random value OUTPUTS HL RAND NUM A L CALLS None CALLED BY Under user program control NOTES None 55 POWER UP INPUT None FUNCTION S Check for the presence of a game cartridge at 08000h If cartridge rom first two bytes 055h and then start game immidiatly Otherwise Turn off sound Initialize pseudo random Initialize controller to strobe reset Set no defered writes to VRAM Set no sprites multiplexing Continuing the execution by displaying the logo screen OUTPUTS None CALLS TURN OFF SOUND CONTROLLER INIT DISPLAY LOGO CALLED BY BOOT UP NOTES None 56 DECLSN ADDRESS 0190 INPUT HL pointer to a byte value FUNCTION S Decrement low nibble LSN of a byte pointed to by HL without affecting the high nibble part MSN OUTPUTS HL old MSN new LSN Z flag set if decrement LSN results in 0 reset otherwise C flag set if decrement LSN results in 1 F reset otherwise 0 new LSN CALLS None CALLED BY FREQ_SWEEP ATN_SWEEP NOTES HL is preserved 57 DECMSN ADDRESS 019B INPUT HL pointer to a byte value FUNCTION S Decrement high nibble MSN part of a byte pointed to by HL without affecting the low nibble part LSN OUTPUTS HL new MSN old LSN Z flag set if decrement MSN results in 0 reset otherwise C flag set if decrement MSN result
169. oft vector 8012 RST 18H RAM Reset 18 soft vector 8015 RST 20H RAM Reset 20 soft vector 8018 RST 28H RAM Reset 28 soft vector 801B RST 30H RAM Reset 30 soft vector 801E INT VECT Software interrupt vector RST 38H 8021 NMI INT VECT NMI soft vector 8024 GAME String of ASCII characters Note Programmers are responsible to use these symbols properly 182 MEMORY MAP From ADAM Technical Reference Manual Note for ADAM users The ADAM computer can be reset in either computer mode or in game mode When the cartridge or ColecoVision reset switch is pressed ADAM resets to game mode In this mode 32K of cartridge ROM are switched into the upper bank of memory and OS 7 plus 24K of intrinsic RAM are switched into the lower bank of memory So it s possible to create a ColecoVision game with additional options if plugged into an ADAM computer and then use the extra RAM space and the ADAM peripherics COLECOVISION GENERAL MEMORY MAP From ColecoVision FAQ ADDRESS DESCRIPTION 0000 1FFF ColecoVision BIOS OS 7 2000 5FFF Expansion port 6000 7FFF 1K RAM mapped into 8K 7000 73FF 8000 FFFF Game cartridge GAME CARTRIDGE HEADER From The Absolute OS 7 Listing ADDRESS NAME DESCRIPTION 8000 8001 CARTRIDGE Test bytes Must be AA55 or 55AA 8002 8003 LOCAL SPR TABLE Pointer to RAM copy of the sprite name tabl 8004 8005 SPRITE ORDER Pointer to RAM sprite order table 8006 8007 WO
170. on generators in the upper half of the stable Programmers should avoid using ACTIVATE to write pattern generators to VRAM graphic mode 1 OR first of all count on having to write the color table seperatly and second count on guarding against corruption by isolating the color table PUT MOBILE PATCH Due to an error near the beginning of the PUT MOBILE routine the beginning part of PUT MOBILE will have to be included as part of the cartridge program Calling the fixed version inside the cartridge instead of the version in the OS has two side effects mobile objects may not be components of a complex object the defered write condition will not be recognized by PUTMOBILE The following code is the section of PUT MOBILE to be part of the cartridge program Remark the red color is used here to show the difference between two 2 versions of PUTMOBILE one for graphic mode 1 and a second for graphic mode 2 WORK BUFFER EQU 8006h FLAGS EQU FRM EQU 4 YDISP EQU 0 XDISP EQU 1 YP_BK EQU 18 XP_BK EQU 17 PX TO PTRN POS GET BKGRND PM2 PUTMOBILE version PUTMOBILE THRI EN EQU 07E8h EQU 0898h EQU OAEOh GRAPHICS MODE I WORK BUFFER FLAGS B DA 8 LD IY XDISP A INC HL LD D HL CALL PX TO PTRN POS LD IYTXP BK E INC HL D E HL D A E AND 7 LD IY YDISP A INC HL LD D HL CALL PX TO PTRN POS LD
171. ors and enlarges it into a block of four the original generator is expanded to four generators are from the pattern plane and the quadruples each of the corresponding color index jump he REFLECT VERTICAL routine 169 call MIRROR L R call PUT TABLE call COLOR TEST cp 001H jr nz END IF 1 GRAPHICS call GET COLOR call PUT COLOR END IF 1 GRAPHICS exx inc hl jr RETURN HERE RLFCT_HOR_ Desc Operations specific to the REFLECT HORIZONTAL routine RLFCT HOR ld hl WORK BUFFER 1 bc 00008H push hl pop de add hl bc ex de hl call IRROR U D call PUT TABLE call COLOR TEST 001H jr nz END IF 2 GRAPHICS call GET COLOR hl WORK BUFFER 1 bc 00008H push hl pop de add hl bc ex de hl call IRROR U D call PUT COLOR END IF 2 GRAPHICS exx inc hl jr RETURN HERE ROT 90 Desc Operations specific to the ROTATE 90 routine ROT 90 ld hl WORK BUFFER ld bc 00008H push hl pop de add hl bc ex de hl call ROTATE call PUT TABLE call COLOR TEST cp 001H nz END IF 3 GRAPHICS call GET COLOR call PUT COLOR END IF 3 GRAPHICS exx inc hl ip RETURN 170 ENLRG Desc Operations specific to the ENLARGE routine ENLRG ld hl WORK BUFFER id bc 00008H push
172. ose of the object s patterns This will then constitute a new frame displaying the object at pattern plane location YP BK XP BK 1 1 hl WORK ER Save index HL Buffer base 123 DLP6 PM12 DVLP DV 1 add 1 id inc inc djnz de YP_BK 1 hl de b 009H hl a a hl DLP6 Point to 15 background name Move newly formed generators to object s pattern and color gen tables Set up pointers to bit 7 43y FLAGS IF PSW IS ZERO JE d ld ld 1 ld ld call push push ld call nz ELSE04 e c 000 bc BK PTN hl bc iy 00009H 003H PUT VRAM iy WORK BUFFI hl WORK BUFF bc BK CLR hl bc ix WORK bc YP_BK 1 ix bc b 009H a ix 000H ix 00H 009 am 003H 003H DVLP 4y XP BK 020H nc NOTOS a b a 4y YP BK 018H nc NOTOS ix hl a 004H iy 00001H PUT VRAM hl WORK BUFFER ER ER ER Test which mode Then mode 1 7 DE Index into pattern generator table HL points to 155 generator 9 elements to send Code for pattern generator table object s pattern names and to color gen bytes L buffer base ffset to color buffer L points to color buffer X buffer base ffset to lst name for object X points
173. ramming documentation For more technical information read Texas Instrument SN76489AN The ColecoVision uses the Texas Instruments SN76489A sound generator chip as the output port Offh It contains three programmable tone generators each with its own programmable attenuator and a noise source with its own attenuator TONE GENERATORS Each tone generator consists of a frequency synthesis section requiring 10 bits of information to define half the period of the desired frequency The frequency can be calculated with the following formula frequency 3 579MHz 32n where n is the 10 bit value NOISE GENERATOR The noise generator consists of a noise source that is a shift register with an exclusive OR feedback network Noise Feedback Control Feedback FB Configuration 0 Periodic Noise buzz 1 White Noise shhh Noise Generator Frequency Control 1 NFO Shift Rate 0 0 N 512 0 1 N 1024 1 0 N 2048 1 1 Tone gen 3 output CONTROL REGISTERS The SN76489A has 8 internal registers which are used to control the 3 tone generators and the noise source During all data transfers to the SN76489A the first byte contains a 3 bits field which determines channel and the control attenuation The channel codes are shown below R1 Destination Control Register 0 0 Tone 1 0 1 2 1 0 3 1 1 Noise 188 The output of the frequency flip flop feeds into a 4 stage attenuator T
174. rs are NAME The screen It contains characters for all the spaces on screen PATTERN The characters pattern 256 characters HEX values from 00 to FF COLOR The characters color s A character has the same pattern and color anywhere on screen one exception with screen mode 2 So you can t use the same character to print a blue A and a red A side by side The solution is using two characters with the same pattern A but with different colors one blue one red You must understand the difference between the ASCII code and the symbol In the ASCII code the character 1 is not the character 1 but the character 49 But by changing the patterns you can make the character 1 looks like a 1 on screen if you like Now if the color of the character 65 41 in HEX value is blue and if you change the pattern of the character 49 31 in HEX value 1 to looks like an A but with a red color then you just have to put the characters and 1 values 65 and 49 side by side on screen to see two A s side by side but one blue and one red In the NAME table there is HEX values 41 for and 31 for the 1 In the PATTERN table there are identical pattern data for the character and 1 In the COLOR table there are different values to set a blue color for the character A and a red color for the character 1 that looks now like an A e Screen mode 0 there are only two colors one color for bits
175. s pointer to the song data area in RAM The first entry in the song table contains the address to the 1 song data area More higher 15 the address of the song data area used by the song more higher is the priority of this song OUTPUT TABLE IN RAM This table in RAM at 7020 7024 contains pointers to the song table and to the active song data areas played through the sound channels For the structure information of this table see the section COMPLET OS 7 RAM MAP at page 184 192 NOTES AND FREQUENCIES From Daniel Bienvenu s CV programming documentation NOTE FREQUENCY CONVERSION TABLE HEX 03F 03B 038 035 032 02 02 02 028 025 023 021 Remark Higher is the frequency lower is its hex corresponding value SCALES A Scale 15 a series of notes which we define as correct or appropriate for a song Examples of various Scales Root C Name C p D E A B Major 1 2 5 6 Major Triad 1 2 3 1 2 3 4 5 6 7 Minor Triad 1 2 3 Harmonic Minor 1 2 3 4 5 6 T Melodic Minor asc 1 2 3 4 5 6 7 Melodic Minor desc 1 2 3 4 5 6 7 Enigmatic 1 2 3 4 5 6 7 Flamenco 1 2 3 4 5 6 7 8 193 VDP VIDEO DISPLAY PROCESSOR From Texas Instrument documentation VDP has 8 control registers 0 7 and 1 status register VDP REGISTERS Register Bits Control registers 7 6 5 4 3 2 1 0 0
176. s ld de hl hl hl hl b hl de hl EOT de de TIMI hl FRE 030H hl r h1 E h1 a b for the user of routine Procedure Test Signal Acc has the Signal number to b value of True 1 Hc dw dw TEST SIGNALQ TESTI SIGNAL MATCH bit jr bit jr SIGNAL FALSE 24 TEST SIG NUM EST SIG PARAM 000 000 Count to next offset Go back up to init timer Maximum of 255 signals allowed Save DE for a work register Save current timer address Go to next available memory location in the Timer Table Save momentarily Get back original timer Reset previous last timer Get back current last timer Restore DE register Go back up and initialize counter for use Put the offset into the Accumulator tested or False 0 Signal given 01H 01H bc TEST SIG PARAM de TEST SIG NU PARAI TEST SIG NU hl b a de a Zio EOT TIMER TABLI E BASI i 00003H IGNAL MATCH r h1 nz SIGNAL FALSI hl de nz TEST1 Fl FREE hl nz SIGNAL FALSE DONE hl nz SIGNAL TRUE S returned in the Accumulator for the Put Signal Code into C register Get Timer Base Address Save Signal Setup offset for next timer See if first timer is a match If so go check it Loop to match timer table to de
177. s in 1 F reset otherwise 0 new MSN CALLS None CALLED BY None NOTES HL is preserved 58 MSNTOLSN ADDRESS 01A6 INPUT HL pointer to a byte value FUNCTION S Copy high nibble MSN part of a byte value pointed to by HL to the low nibble part LSN opf that byte OUTPUTS HL MSN MSN CALLS None CALLED BY FREQ SWEEP ATN SWEEP NOTES HL is preserved 59 ADD816 ADDRESS 0181 INPUT HL pointer to a word value A signed byte value 128 127 FUNCTION S Adds 8 bit two s complement signed value passed in A to the 16 bit value pointed to by HL OUTPUTS HL HL A CALLS None CALLED BY FREQ SWEEP NOTES HL is returned intact 60 DISPLAY LOGO DESCRIPTION Displays the Coleco logo screen with COLECOVISION on a black background If no cartridge 18 detected a default message is displayed during 60 seconds instructing the operator to turn game off before inserting cartridge or expansion module Otherwise the game title manufacturer and copyright year are obtained from the cartridge and overlayed onto the logo screen for a period of 10 seconds before game starts INPUT None FUNCTION S Clean up the 16K VRAM 0000h 4000h Set default screen mode 1 by calling MODE 1 Load default ASCII by calling LOAD ASCII Load logo pattern Put logo on screen Add beside the logo Put year 1982 centered at the bottom Load logo colors Enable display Test if
178. s of default NMI handler 73C6 DEFER WRITES Deferred sprites flag 1361 MUX SPRITES Multiplexing sprites flag 73C8 73C9 RAND NUM Pseudo random number value 73CA QUEUE SIZE Size of the deferred write queu 73CB QUEUE HEAD Indice of the head of the write queue 73CC QUEUE TAIL Indice of the tail of the write queue 73CD 73CE HEAD ADDRE Address of the queue head 73 73 0 TAIL ADDRE Address of the queue tail 73D1 73D2 BUFFER Buffer pointer to deferred objects 73D3 73D4 TIMER TABLE BASE Timer base address 7305 7306 NEXT TIMER DATA BYTE Next available timer address 9 i Debounce buffer 5 pairs old and state 73D7 73EA DBNCE BUFF of fire joy spin arm and kbd for each 731 731 731 731 73EF 73F0 73F1 73F2 73FB 73F2 13F3 73F4 73F5 13 6 173 7 73 8 73 9 73FA 73FB 73FC 73FD 73FE 73FF GI B C LI lt i E SPIN 50 CT SPIN 501 CT 50 CO 50 1 S1 CO S1 C1 VRAM ADDR TABLE SPRITENAMETBL SPRITEGENTBL PATTE PATTE COLORTABLE SAVE TEMP SAV td Q O player Spinner counter port l Spinner counter port 2 reserved Segment 0 data Controller port 1 Segment 0 data Controller port 2 Segment 1 data Controller port 1 Segment 1 data Controller port 2 Block of VRAM table pointers Sprite name table offset Sprite generator table offset Pattern name table offset Pattern generator table offset Co
179. sed in HL IX 1s assumed to be pointing to byte 0 of the data area to which the song number is to be restored Bits 7 amp 6 of the saved SONGNO byte are not stored into byte 0 and therefore may be used during the course of the effect to store any useful flag information OUTPUTS None CALLS None CALLED BY Called by a special sound effect routine when it s finished NOTES None 12 AREA SONG 15 INPUT IX address of byte 0 of a song data area FUNCTION S Retrive in the song playing in a specific song data area pointed to by IX OUTPUTS Accumulator song of the song using that area FF if inactive 62 if special effect and HL address of the special sound effect routine CALLS None CALLED BY PROCESS DATA AREA NOTES None 13 SOUND INIT ADDRESS INPUT HL 257 OF SND ADDRS address in RAM to song data areas B of song data areas to initialize FUNCTION S Set pointer PTR TO LST OF SND ADDRS to LST OF SND ADDRS Store inactive code FF at byte 0 of the song data areas Store 00 at end of song data areas Sets the 4 channel sound pointers to a dummy inactive data area Initialize SAVE to inactive code FF Turn off sound OUTPUTS None CALLS ALL OFF local routine name for TURN OFF SOUND CALLED BY Under user program control Should be called immediately after power on NOTES IX and IY are preserved 14 TURN OFF SOUND ADDRESS 1 06
180. sired timer Check for end of table If so then return a not done Now index to next timer Decrement to the timer desired If not a timer desired timer then go back Here with a timer match Check for timer done If so then go return a True Here to return a false for either a not done or non existent timer 137 SIGNAL TRUE SIGNAL TRU jr bit FE set res ld EXIT or rec Fl H TEST_EXIT REPEAT hl SIGNAL TRUE1 E h1 DN DONE 11 a 001H a Put a false in Acc Got to the exit Here when timer is finished Check for repeating timer If so then just return True Fr current timer since not repeating Start add 4 30 82 Reset current timer to not done End 4 30 82 Put a true in the Acc Return 138 CONTROLLER SOFTWARE Defines NUM DEV EQU 005H KDB NULL EQU CONTROLLER 0 EQU 000H STROBE SET EQU 001H FIRE MASK EQU 040H JOY MASK EQU OOFH ARM MASK EQU 040H KBD MASK EQU OOFH PLYR 0 EQU 00002H PLYR 1 EQU 00007H SEG 0 EQU 007H SEG 1 EQU 018H FIRE EQU 000H JOY EQU 001H SPIN EQU 002H ARM EQU 003H KBD EQU 004H FIRE OLD EQU 000H FIRE STATE EQU JOY OLD EQU 002H JOY STATE EQU SPIN OLD EQU 004H SPIN STATE EQU ARM OLD EQU 006H ARM S
181. stroy AF BC DE QUADRUPLE ld push QUAD LOOP SKIPZZ bc 00010H hl a hl hl de a de de a de bc a c 008H nz SKIPZZ hl b nz QUAD LOOP 174 MIRROR ROTATE RTN The routines in this file take a single 8 byte block as input and operate on it producing a single 8 byte block as output They perform mirroring arround the vertical axis mirroring arround the horizontal axis Global GLB MIRROR L R MIRROR U D ROTATE MIRROR L R Desc Input and 90 degree rotation Reflets an 8x8 pixel data block arround the vertical axis HL Source pointer D E Destination pointer Destroy AF BC DE HL MIRROR L R ld bc 00008H MIR L R10 1 1 080 MIR L R20 rl b rra jr nc MIR L R20 Ld de a inc hl inc de dec jr nz MIR L R10 ret ROTATE Desc Rotate object 90 degrees clockwise Input HL Source pointer DE Destroy IX AF BC DE E Destination pointer ROTATE push hl pop ix ex de hl ld bc 00008H TRANSP 10 rl ix 000H rr hl i 1 001 1 rl 1 002 re hl rl ix 003H 1 rl 1 004 1 rl ix 005H er hl rl ix 006H EE h1 rl ix 007H xt hl inc hl dec c oy HL 175 MIRROR U D filler 1f5d MIRROR U D Desc Input jr ret HL Sourc
182. sw is zero FPSV has timed out JE nz L21 decrement NLEN and leave if sweep is over call MSNTOLSN reload FPSV from FPS dec hl point to NLEN steps in the sweep id a hl decrement NLEN and dec a SET Z flag if 0 ret 2 leave if sweep over with 2 flag set 3 sweep not over so add FSTEP to ld hl a Store decremented NLEN dec hl point HL to FREQ dec hl 1 1 007 A FSTEP two s complement step size call ADD816 PSEREQ FREQ FSTEP inc hl point HL to hi FREQ res 2 hl RESET B2 in hi FREQ in case add cased 10 bit or RESET Z flag sweep not over yet L21 ret 74 ATTENUATION SWEEP RTN IDENT ATNSWEE includes ATN SWEEP INCLUDE OSSR_EQU 0S 0 equates Globals GLB ATN SWEEP Externals GLB DECLSN DECMSN MSNTOLSN Defines APSV EQU 009H ke kc kc ke ATN SWEEP COMMENT See User s Manual for description RETs Z SET if byte 8 is 0 means sweep is over or note was never swept RETs Z RESET if sweep in progress i ATN_SWEEP RET with 2 SET if byte 8 00 id a ix 008H check byte 8 for no sweep code cp 000H Z is set if byte 8 0 ret 2 leave if Z set sweep not going sweep going so dec APSV push ix point HL to APSV pop hl 1
183. t of sla a COLOR entry ld bc 00000H id hl add hl bc HL Color ld a hl ld iy COLOR AND TAG a End if PUT Y AND NAME Y BYTE STATUS Y LOCATION ld l 4x STATUS ld h 1x STATUS 1 ld de LOCATION add hl de HL Y LOCATION ld a hl ld iy Y a NAME GRAPHICS FRAME TABLE STATUS FRAME SHAPE GRAPHICS FIRST GEN NAME ld 1 ix GRAPHICS ld h ix GRAPHICS 1 ld de FRAME TABLE PTR add hl de HL FRAME TABLE PTR ex de hl id a de 1 1 114 E m HL FRAME TABLE PTR HL FRAME Calculate offset of SHAPE entry HL SHAPE HL FIRST GEN NAME _ INDEX SPRITE 1 Count of one item E m h Screen by setting its X and early cloack _ INDEX SPRITE 1 Save index regs Count of one item INDEX SPRITE 1 1 1 push hl ld l 1x STATUS 1 h ix STATUS 1 ld de FRAME add hl de ld hl sla a 1 bc 00000H ld hl add hl bc inc hl 1 hl 1 x GRAPHICS 1 h 43xtGRAPHICS 1 ld de FIRST GEN NAME add hl de add a hl ld 1 PUT VRAM 0 5 SPRITE SPRIT 1 000 1 ix SPRITE INDEX push iy pop hl ld iy 00001H call jr EXIT P
184. ter 1 in order to enable the interrupt for each frame and then read the status register each time an interrupt 1s issued to clear the interrupt output See NMI section for details NMI Non Maskable Interrupt The VDP output pin is used to generate an interrupt at the end of each active display scan which is about every 1 60 second for the TMS9928A NTSC and 1 50 second for the TMS9929A PAL The interupt output signal is active when the generate interrupts bit GINT in VDP Register 1 is set and the bit 7 INT of the status register is set Interrupts are cleared when status register is read In other words After a vertical retrace refresh done the bit 7 of the status register is set If GINT bit 5 of control register 1 is set the NMI interrupts the normal execution e When it s time again to refresh the bit 7 of the status register is reset NMI can be used to execute something again and again at a regular speed like updating graphics sounds or calling the game engine game loop 196 COLOR PALETTE COLOR COLOR Y R Y B Y 0 Invisible 1 Black 0 00 0 47 0 47 2 Medium Green 0 53 0 07 0 20 3 Light Green 0 67 0 17 0 27 4 Dark blue 0 40 0 40 1 00 5 Light blue 0 53 0 43 0 93 6 Dark Red brown 0 47 0 83 0 30 7 Cyan 0 73 0 00 0 70 8 Medium Red 0 53 0 93 0 27 9 Light Red Pink orange 0 67 0 93 0 27 10 A Dark Yellow Yellow 0 73 0 57 0 07 11
185. thode of combining object generators METHODE OF COMBINING OBJECT GENERATORS Object pattern gens ored with background pattern gens colorl of background changed to mobile object s color not zero 1 2 if corresponding patt 2 treat color same as 1 3 4 rn byt Replace background pattern gens with object pattern gens Same as 41 except color0 changed to transparent Same as 2 except 0 changed to transparent ke ce ke ke he ke ke KR ke e heck e e ke ke ke he he ke he ke he ke ke he ke Sk e ke ke khe he ke e he ke kc e he ke e he heck e ke ke e he ke ke he he ke e ke e ke i EXT EXT GLB Defines 3 The following are offsets from the start of th 5 UT MOBILE READ VRAM WRITE VRAM WORK BUFFER GET VRAM PUT VRAM PX TO PTRN POS GET BKGRND VDP MODE WORD PUTFRAM buffer area These locations used to store variables and pattern and color data YDISP XDISP COLR FLAGS FRM F GEN YP OS XP OS YP BK XP BK BK PTN E OBJ PTN PUT MOBILE 1 1 EQU 0 Y Displacement EQU 1 X Displacement EQU 2 Color EQU 3 BITS 0 1 Selector BIT X Graphics Mode I II EQU 4 Frame to be Displayed EQU 5 of 1st generator in object s gen table EQU 7 Y PAT POS of OLD SCREEN EQU 6 X PAT POS of OLD SCREEN EQU 18 Y
186. to note list starting addr entry in LST OF SND ADDRS is he initial value for NEXT NOTE PTR EXT NOTE PTR for 1st note in song load note byte 0 CH SONGNO set new NEXT NOTE PTR RS new song so update channel data ptrs dw 00001H dw 00001H JUKE ld bc JUKE BOX PAR 1 de PARAM AREA call PARAM _ ld a PARAM AREA 1 b a JUKE BOX RET if song already in progress push bc call PT IX TO SxDATA id a 1 000 and 03FH pop bc b ret 2 load 1st note and set NEXT NOTE ld ix 000H b dec hl HL left pointing to dec hl entry in LS ld d h1 and save th dec hl addr in DE id e hl DE now has t id ix 001H e ix 002H d call LOAD NEXT call UP CH DATA PT ret 82 SOUND MANAGER IDENT SNDMAN includes TONE OUT ko kc ke kc ko ke ke koe e ke ke ke ke KK SONG MANAGER pOKCKOKCK kk ko kk ke koe ke kc kc ke ke COMMENT See Users Manual for description i Globals GLB SND MANAGER 5 GLB UP CH DATA PTRS GLB PROCESS DATA AREA GLB EFXOVER Externals EXT PT IX TO SxDATA AREA SONG IS EXT DUMAREA 7 EXT OAD NEXT NOTE ATN SWEEP FREQ SWEEP INCLUDE OSSR_EQU 0S 0 equates ENDSDATA EQU 000H INACTIVE EQU OFFH SND MANAGER IX addr o
187. tton Else joystick active Debounce joystick data If fire button is not active Then check spinner Else fire button active Debounce fire button If spinner is not active Then exit decoder Else spinner active Save spinner count in controller memory Clear counter status buffer Save data If ARM button not active 143 jr call ld DEC KBD bit jr call DECODE 1X ret 2 Then check keyboard Else ARM button active ARM DBNCE Debounce ARM button a c KBD b If keyboard not active z DECODE 1X Then exit decoder Else keyboard active KBD DBNCE Debounce keyboard Keyboard debounce routine Input A Raw data IX Controller memory pointer IY Debounce status buffer KBD DBNCE push bc push de push hl and KBD MASK Mask out valid data ld e a and save it ld b iy KBD OLD Get old data id a 4y KBD STATE and current status cp 000H If state lt gt 0 jr nz KBD 5 1 Then must be state 1 KBD STO Else state 0 ld a e Get current data b If old new jr z KBD REG Then saw data twice in sequence ld OLD e Else first time save current data JE KBD EXIT KBD_REG ld a 001H Set state 1 ld 1y KBD STATE a ld hl DEC KBD TBL Decode table address 1 000 D E raw data add hl de Compute address into table ld a hl Do table
188. x inc inc rlca jp inc pop ex ld inc ld inc pop ex dec push rrca ld dec ld ld sp hl e 11 hl d h1 m DO a bc nc L00DA bc hl sp hl hl e hl 1 hl de sp hl hl a h 2 100 0 1 z LOOD6 sp hl hl de hl L00A3 hl de hl sp hl 1 INFO index jump 70 ex sp hl inc bc inc bc LOOES ld a de ld hl a inc hl inc de ex sp hl dec hl l jp 2 100 4 h jp 2 100 8 LOOF4 ex sp hl jp 00E5 LOOF8 pop hl jp 100 4 Po SYSTEM RAM AREA SYSTEM RAM AREA EQU 073BAH This is the RAM area dedicated to the basic OS needs It includes the Stack various status variables and all the variables used by OS routines STACK EQU SYSTEM RAM AREA 1 This is the TOP of the STACK PARAM AREA EQU 073BAH 9 bytes This is the common parameter passing area and the hole in the data area that is provided to make room for it To extract the parameters PASCAL CALLS To initialize sound and timer data ETC TIMER LENGTH EQU 073COH TEST SIG NUM EQU 073C2H VDP MODE WORD EQU 073c3H 2 bytes The VDP mode word contains a copy of the data in the 156 two VDP registers By examining this data the OS and cartrid

Download Pdf Manuals

image

Related Search

Related Contents

OptojumpNext User Manual IT  Textura Viewpoint Integration Manual  Waterfinder  56F805 - HW.cz  Samsung NP900X3D User Manual (Windows 8)  

Copyright © All rights reserved.
Failed to retrieve file