├── .gitignore ├── Amiga ├── AmigaRobots.info ├── AnimTiles.raw ├── C64Font.raw ├── Data │ ├── GameOver.raw.gz │ ├── GameScreen.raw.gz │ ├── IntroScreen.raw.gz │ ├── level-a.gz │ ├── level-b.gz │ ├── level-c.gz │ ├── level-d.gz │ ├── level-e.gz │ ├── level-f.gz │ ├── level-g.gz │ ├── level-h.gz │ ├── level-i.gz │ ├── level-j.gz │ ├── level-k.gz │ ├── level-l.gz │ ├── level-m.gz │ ├── level-n.gz │ ├── mod.get psyched.gz │ ├── mod.lose.gz │ ├── mod.metal heads.gz │ ├── mod.metallic bop amiga.gz │ ├── mod.robot attack.gz │ ├── mod.rushin in.gz │ └── mod.win.gz ├── Disk.info ├── Faces.raw ├── Health.raw ├── Install ├── Install.info ├── Items.raw ├── Keys.raw ├── PETFont.raw ├── PETRobots.info ├── Sprites.raw ├── SpritesMask.raw ├── SquareWave.raw ├── Tiles.raw ├── WHDLoad │ ├── PETSCIIRobotsInstall.info │ └── PETSCIIRobotsInstall │ │ ├── Install │ │ ├── Install.info │ │ ├── PETSCIIRobots.inf │ │ ├── ReadMe │ │ ├── ReadMe.info │ │ └── Source │ │ ├── PETSCIIRobots.s │ │ ├── kick13.s │ │ ├── kickfs.s │ │ └── makefile ├── amigaicon.iff ├── animtiles.png ├── c │ ├── Avail │ ├── Check512k │ ├── Echo │ ├── Endif │ └── If ├── c64font.png ├── devs │ └── system-configuration ├── faces.png ├── gameover.png ├── gamescreen.png ├── health.png ├── introscreen.png ├── items.png ├── keys.png ├── move.iff ├── petfont.png ├── peticon.iff ├── s │ └── startup-sequence ├── search.iff ├── sprites.png ├── spritesalpha.png ├── spritesmask.png ├── tiles.png └── tilesalpha.png ├── Arcade ├── .gitignore ├── Attract1.png ├── Attract1.raw ├── Attract2.png ├── Attract2.raw ├── Attract3.png ├── Attract3.raw ├── Data │ └── IntroScreen.raw.gz ├── introscreen.png └── setup.sh ├── DecompressData.c ├── LICENCE1 ├── Music ├── mod.get psyched ├── mod.lose ├── mod.metal heads ├── mod.metallic bop amiga ├── mod.robot attack ├── mod.rushin in ├── mod.soundfx └── mod.win ├── PT2.3F_replay_cia.h ├── PT2.3F_replay_cia.s ├── Palette.cpp ├── Palette.h ├── Platform.cpp ├── Platform.h ├── PlatformAmiga.cpp ├── PlatformAmiga.h ├── PlatformAmigaAssembler.s ├── README ├── SCoptions.amiga ├── SCoptions.arcade ├── SCoptions.pet ├── SCoptions.shareware ├── Shareware ├── .gitignore ├── AttackOfThePETSCIIRobots.readme └── setup.sh ├── Sounds ├── SOUND_BEEP.raw ├── SOUND_BEEP2.raw ├── SOUND_CYCLE_ITEM.raw ├── SOUND_CYCLE_WEAPON.raw ├── SOUND_DOOR_FASTER.raw ├── SOUND_EMP.raw ├── SOUND_ERROR.raw ├── SOUND_FOUND_ITEM.raw ├── SOUND_MAGNET2.raw ├── SOUND_MEDKIT.raw ├── SOUND_MOVE.raw ├── SOUND_PLASMA_FASTER.raw ├── SOUND_SHOCK.raw ├── sounds_dsbarexp.raw └── sounds_dspistol.raw ├── Tiletool ├── .gitignore ├── Tiletool.pro └── main.cpp ├── petrobots.cpp ├── petrobots.h ├── smakefile ├── smakefile.arcade ├── smakefile.pet ├── smakefile.shareware ├── tileset.amiga ├── tileset.pet ├── ungzip.h └── ungzip.s /.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | *.lnk 3 | *.uaem 4 | .DS_Store 5 | AmigaRobots 6 | PETRobots 7 | ArcadeRobots 8 | SharewareRobots 9 | DecompressData 10 | PETSCIIRobots.slave 11 | *.lha 12 | *.adf 13 | -------------------------------------------------------------------------------- /Amiga/AmigaRobots.info: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeropolis79/PETSCIIRobots-Amiga/266132967fd50eb44080d90c8221c2449daaf540/Amiga/AmigaRobots.info -------------------------------------------------------------------------------- /Amiga/AnimTiles.raw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeropolis79/PETSCIIRobots-Amiga/266132967fd50eb44080d90c8221c2449daaf540/Amiga/AnimTiles.raw -------------------------------------------------------------------------------- /Amiga/C64Font.raw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeropolis79/PETSCIIRobots-Amiga/266132967fd50eb44080d90c8221c2449daaf540/Amiga/C64Font.raw -------------------------------------------------------------------------------- /Amiga/Data/GameOver.raw.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeropolis79/PETSCIIRobots-Amiga/266132967fd50eb44080d90c8221c2449daaf540/Amiga/Data/GameOver.raw.gz -------------------------------------------------------------------------------- /Amiga/Data/GameScreen.raw.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeropolis79/PETSCIIRobots-Amiga/266132967fd50eb44080d90c8221c2449daaf540/Amiga/Data/GameScreen.raw.gz -------------------------------------------------------------------------------- /Amiga/Data/IntroScreen.raw.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeropolis79/PETSCIIRobots-Amiga/266132967fd50eb44080d90c8221c2449daaf540/Amiga/Data/IntroScreen.raw.gz -------------------------------------------------------------------------------- /Amiga/Data/level-a.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeropolis79/PETSCIIRobots-Amiga/266132967fd50eb44080d90c8221c2449daaf540/Amiga/Data/level-a.gz -------------------------------------------------------------------------------- /Amiga/Data/level-b.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeropolis79/PETSCIIRobots-Amiga/266132967fd50eb44080d90c8221c2449daaf540/Amiga/Data/level-b.gz -------------------------------------------------------------------------------- /Amiga/Data/level-c.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeropolis79/PETSCIIRobots-Amiga/266132967fd50eb44080d90c8221c2449daaf540/Amiga/Data/level-c.gz -------------------------------------------------------------------------------- /Amiga/Data/level-d.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeropolis79/PETSCIIRobots-Amiga/266132967fd50eb44080d90c8221c2449daaf540/Amiga/Data/level-d.gz -------------------------------------------------------------------------------- /Amiga/Data/level-e.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeropolis79/PETSCIIRobots-Amiga/266132967fd50eb44080d90c8221c2449daaf540/Amiga/Data/level-e.gz -------------------------------------------------------------------------------- /Amiga/Data/level-f.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeropolis79/PETSCIIRobots-Amiga/266132967fd50eb44080d90c8221c2449daaf540/Amiga/Data/level-f.gz -------------------------------------------------------------------------------- /Amiga/Data/level-g.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeropolis79/PETSCIIRobots-Amiga/266132967fd50eb44080d90c8221c2449daaf540/Amiga/Data/level-g.gz -------------------------------------------------------------------------------- /Amiga/Data/level-h.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeropolis79/PETSCIIRobots-Amiga/266132967fd50eb44080d90c8221c2449daaf540/Amiga/Data/level-h.gz -------------------------------------------------------------------------------- /Amiga/Data/level-i.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeropolis79/PETSCIIRobots-Amiga/266132967fd50eb44080d90c8221c2449daaf540/Amiga/Data/level-i.gz -------------------------------------------------------------------------------- /Amiga/Data/level-j.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeropolis79/PETSCIIRobots-Amiga/266132967fd50eb44080d90c8221c2449daaf540/Amiga/Data/level-j.gz -------------------------------------------------------------------------------- /Amiga/Data/level-k.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeropolis79/PETSCIIRobots-Amiga/266132967fd50eb44080d90c8221c2449daaf540/Amiga/Data/level-k.gz -------------------------------------------------------------------------------- /Amiga/Data/level-l.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeropolis79/PETSCIIRobots-Amiga/266132967fd50eb44080d90c8221c2449daaf540/Amiga/Data/level-l.gz -------------------------------------------------------------------------------- /Amiga/Data/level-m.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeropolis79/PETSCIIRobots-Amiga/266132967fd50eb44080d90c8221c2449daaf540/Amiga/Data/level-m.gz -------------------------------------------------------------------------------- /Amiga/Data/level-n.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeropolis79/PETSCIIRobots-Amiga/266132967fd50eb44080d90c8221c2449daaf540/Amiga/Data/level-n.gz -------------------------------------------------------------------------------- /Amiga/Data/mod.get psyched.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeropolis79/PETSCIIRobots-Amiga/266132967fd50eb44080d90c8221c2449daaf540/Amiga/Data/mod.get psyched.gz -------------------------------------------------------------------------------- /Amiga/Data/mod.lose.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeropolis79/PETSCIIRobots-Amiga/266132967fd50eb44080d90c8221c2449daaf540/Amiga/Data/mod.lose.gz -------------------------------------------------------------------------------- /Amiga/Data/mod.metal heads.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeropolis79/PETSCIIRobots-Amiga/266132967fd50eb44080d90c8221c2449daaf540/Amiga/Data/mod.metal heads.gz -------------------------------------------------------------------------------- /Amiga/Data/mod.metallic bop amiga.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeropolis79/PETSCIIRobots-Amiga/266132967fd50eb44080d90c8221c2449daaf540/Amiga/Data/mod.metallic bop amiga.gz -------------------------------------------------------------------------------- /Amiga/Data/mod.robot attack.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeropolis79/PETSCIIRobots-Amiga/266132967fd50eb44080d90c8221c2449daaf540/Amiga/Data/mod.robot attack.gz -------------------------------------------------------------------------------- /Amiga/Data/mod.rushin in.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeropolis79/PETSCIIRobots-Amiga/266132967fd50eb44080d90c8221c2449daaf540/Amiga/Data/mod.rushin in.gz -------------------------------------------------------------------------------- /Amiga/Data/mod.win.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeropolis79/PETSCIIRobots-Amiga/266132967fd50eb44080d90c8221c2449daaf540/Amiga/Data/mod.win.gz -------------------------------------------------------------------------------- /Amiga/Disk.info: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeropolis79/PETSCIIRobots-Amiga/266132967fd50eb44080d90c8221c2449daaf540/Amiga/Disk.info -------------------------------------------------------------------------------- /Amiga/Faces.raw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeropolis79/PETSCIIRobots-Amiga/266132967fd50eb44080d90c8221c2449daaf540/Amiga/Faces.raw -------------------------------------------------------------------------------- /Amiga/Health.raw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeropolis79/PETSCIIRobots-Amiga/266132967fd50eb44080d90c8221c2449daaf540/Amiga/Health.raw -------------------------------------------------------------------------------- /Amiga/Install: -------------------------------------------------------------------------------- 1 | (set #prefix "PETSCIIRobots") 2 | 3 | (set #dest 4 | (askdir 5 | (prompt 6 | (cat 7 | "Where should \"" @app-name "\" be installed?\n" 8 | "A drawer \"" #prefix "\" will be automatically created." 9 | ) 10 | ) 11 | (help @askdir-help) 12 | (default @default-dest) 13 | ) 14 | ) 15 | 16 | (set @default-dest #dest) 17 | (set #dest (tackon #dest #prefix)) 18 | (set #dest-org #dest) 19 | (set #dest-data (tackon #dest "Data")) 20 | 21 | (if 22 | (exists #dest) 23 | ( 24 | (set #choice 25 | (askbool 26 | (prompt 27 | (cat 28 | "\nDirectory \"" #dest "\" already exists.\n" 29 | "Should it be deleted?" 30 | ) 31 | ) 32 | (default 1) 33 | (choices "Delete" "Skip") 34 | (help @askbool-help) 35 | ) 36 | ) 37 | (if 38 | (= #choice 1) 39 | (run ("Delete \"%s\" \"%s.info\" All" #dest #dest)) 40 | ) 41 | ) 42 | ) 43 | (makedir #dest 44 | (help @makedir-help) 45 | (infos) 46 | ) 47 | 48 | (copyfiles 49 | (help @copyfiles-help) 50 | (source "AmigaRobots") 51 | (dest #dest) 52 | (infos)) 53 | 54 | (copyfiles 55 | (help @copyfiles-help) 56 | (source "PETRobots") 57 | (dest #dest) 58 | (infos)) 59 | 60 | (makedir 61 | (help @makedir-help) 62 | #dest-data) 63 | 64 | (working "Decompressing data files") 65 | 66 | (foreach 67 | "Data" 68 | "#?.gz" 69 | ((set #source-file (tackon "Data" @each-name)) 70 | (set #dest-file (tackon #dest-data (substr @each-name 0 (- (strlen @each-name) 3)))) 71 | (working "Decompressing " #source-file " to " #dest-file) 72 | (run ("C/DecompressData \"%s\" \"%s\"" #source-file #dest-file)))) 73 | -------------------------------------------------------------------------------- /Amiga/Install.info: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeropolis79/PETSCIIRobots-Amiga/266132967fd50eb44080d90c8221c2449daaf540/Amiga/Install.info -------------------------------------------------------------------------------- /Amiga/Items.raw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeropolis79/PETSCIIRobots-Amiga/266132967fd50eb44080d90c8221c2449daaf540/Amiga/Items.raw -------------------------------------------------------------------------------- /Amiga/Keys.raw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeropolis79/PETSCIIRobots-Amiga/266132967fd50eb44080d90c8221c2449daaf540/Amiga/Keys.raw -------------------------------------------------------------------------------- /Amiga/PETFont.raw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeropolis79/PETSCIIRobots-Amiga/266132967fd50eb44080d90c8221c2449daaf540/Amiga/PETFont.raw -------------------------------------------------------------------------------- /Amiga/PETRobots.info: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeropolis79/PETSCIIRobots-Amiga/266132967fd50eb44080d90c8221c2449daaf540/Amiga/PETRobots.info -------------------------------------------------------------------------------- /Amiga/Sprites.raw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeropolis79/PETSCIIRobots-Amiga/266132967fd50eb44080d90c8221c2449daaf540/Amiga/Sprites.raw -------------------------------------------------------------------------------- /Amiga/SpritesMask.raw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeropolis79/PETSCIIRobots-Amiga/266132967fd50eb44080d90c8221c2449daaf540/Amiga/SpritesMask.raw -------------------------------------------------------------------------------- /Amiga/SquareWave.raw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeropolis79/PETSCIIRobots-Amiga/266132967fd50eb44080d90c8221c2449daaf540/Amiga/SquareWave.raw -------------------------------------------------------------------------------- /Amiga/Tiles.raw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeropolis79/PETSCIIRobots-Amiga/266132967fd50eb44080d90c8221c2449daaf540/Amiga/Tiles.raw -------------------------------------------------------------------------------- /Amiga/WHDLoad/PETSCIIRobotsInstall.info: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeropolis79/PETSCIIRobots-Amiga/266132967fd50eb44080d90c8221c2449daaf540/Amiga/WHDLoad/PETSCIIRobotsInstall.info -------------------------------------------------------------------------------- /Amiga/WHDLoad/PETSCIIRobotsInstall/Install: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeropolis79/PETSCIIRobots-Amiga/266132967fd50eb44080d90c8221c2449daaf540/Amiga/WHDLoad/PETSCIIRobotsInstall/Install -------------------------------------------------------------------------------- /Amiga/WHDLoad/PETSCIIRobotsInstall/Install.info: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeropolis79/PETSCIIRobots-Amiga/266132967fd50eb44080d90c8221c2449daaf540/Amiga/WHDLoad/PETSCIIRobotsInstall/Install.info -------------------------------------------------------------------------------- /Amiga/WHDLoad/PETSCIIRobotsInstall/PETSCIIRobots.inf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeropolis79/PETSCIIRobots-Amiga/266132967fd50eb44080d90c8221c2449daaf540/Amiga/WHDLoad/PETSCIIRobotsInstall/PETSCIIRobots.inf -------------------------------------------------------------------------------- /Amiga/WHDLoad/PETSCIIRobotsInstall/ReadMe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeropolis79/PETSCIIRobots-Amiga/266132967fd50eb44080d90c8221c2449daaf540/Amiga/WHDLoad/PETSCIIRobotsInstall/ReadMe -------------------------------------------------------------------------------- /Amiga/WHDLoad/PETSCIIRobotsInstall/ReadMe.info: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeropolis79/PETSCIIRobots-Amiga/266132967fd50eb44080d90c8221c2449daaf540/Amiga/WHDLoad/PETSCIIRobotsInstall/ReadMe.info -------------------------------------------------------------------------------- /Amiga/WHDLoad/PETSCIIRobotsInstall/Source/PETSCIIRobots.s: -------------------------------------------------------------------------------- 1 | ; Attack of the PETSCII Robots WHDLoad slave by Vesa Halttunen 2 | ; Based on example slave code by wepl 3 | 4 | INCDIR "INCLUDE:" 5 | INCLUDE "whdload.i" 6 | INCLUDE "whdmacros.i" 7 | INCLUDE "libraries/dos_lib.i" 8 | 9 | OUTPUT "PETSCIIRobots.slave" 10 | BOPT O+ 11 | BOPT OG+ 12 | BOPT ODd- 13 | BOPT ODe- 14 | BOPT w4- 15 | BOPT wo- 16 | SUPER 17 | 18 | BLACKSCREEN 19 | CHIPMEMSIZE = $80000 20 | FASTMEMSIZE = $40000 21 | NUMDRIVES = 1 22 | WPDRIVES = %0000 23 | HDINIT 24 | IOCACHE = 5000 25 | SETPATCH 26 | BOOTDOS 27 | 28 | slv_Version = 16 29 | slv_Flags = WHDLF_NoError|WHDLF_Examine 30 | slv_keyexit = $59 ; F10 31 | 32 | INCLUDE "kick13.s" 33 | 34 | dc.b "$VER: PETSCIIRobots.slave 1.2 (25.03.2022)",0 35 | 36 | slv_CurrentDir: dc.b "Data",0 37 | slv_name: dc.b "Attack of the PETSCII Robots",0 38 | slv_copy: dc.b "2021 8-Bit Productions, LLC.",0 39 | slv_info: dc.b "Adapted by Vesa Halttunen",10 40 | dc.b "Version 1.2 (25.03.2022)",0 41 | programName: dc.b "AmigaRobots",0 42 | args: dc.b 10 43 | argsEnd: dc.b 0 44 | EVEN 45 | 46 | _bootdos: 47 | move.l _resload,a2 48 | lea programName(pc),a3 49 | 50 | lea _dosname(pc),a1 51 | move.l 4.w,a6 52 | jsr _LVOOldOpenLibrary(a6) 53 | move.l d0,a6 54 | 55 | move.l a3,d1 56 | jsr _LVOLoadSeg(a6) 57 | tst.l d0 58 | bne.s .checkVersion 59 | 60 | .readFailure: 61 | jsr _LVOIoErr(a6) 62 | move.l a3,-(sp) 63 | move.l d0,-(sp) 64 | pea TDREASON_DOSREAD 65 | move.l _resload(pc),-(sp) 66 | add.l #resload_Abort,(sp) 67 | rts 68 | 69 | .checkVersion: 70 | add.l d0,d0 71 | add.l d0,d0 72 | addq #4,d0 73 | move.l d0,a4 74 | 75 | move.l a3,d1 76 | move.l #MODE_OLDFILE,d2 77 | jsr _LVOOpen(a6) 78 | move.l d0,d1 79 | beq.s .readFailure 80 | 81 | move.l #300,d3 82 | sub.l d3,sp 83 | move.l sp,d2 84 | jsr _LVORead(a6) 85 | 86 | move.l d3,d0 87 | move.l sp,a0 88 | jsr resload_CRC16(a2) 89 | 90 | add.l d3,sp 91 | 92 | cmp.w #$20af,d0 ; version 1.0 93 | beq .checkJSR 94 | cmp.w #$ce1b,d0 ; version 1.1 95 | beq .start 96 | cmp.w #$e283,d0 ; version 1.2 97 | beq .start 98 | 99 | .wrongVersion: 100 | pea TDREASON_WRONGVER 101 | jmp resload_Abort(a2) 102 | 103 | .checkJSR: 104 | cmp.w #$4e92,$2a68(a4) ; jsr(a2) 105 | bne.s .wrongVersion 106 | 107 | lea patchList(pc),a0 108 | move.l a4,a1 109 | jsr resload_Patch(a2) 110 | 111 | .start: 112 | lea args(pc),a0 113 | move.l 4(sp),d0 114 | sub.l #5*4,d0 115 | moveq #argsEnd-args,d0 116 | jsr (a4) 117 | 118 | move.l _resload,a2 119 | pea TDREASON_OK 120 | jmp resload_Abort(a2) 121 | 122 | patchList: 123 | PL_START 124 | PL_NOPS $2a68,1 125 | PL_END 126 | 127 | END 128 | -------------------------------------------------------------------------------- /Amiga/WHDLoad/PETSCIIRobotsInstall/Source/kick13.s: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeropolis79/PETSCIIRobots-Amiga/266132967fd50eb44080d90c8221c2449daaf540/Amiga/WHDLoad/PETSCIIRobotsInstall/Source/kick13.s -------------------------------------------------------------------------------- /Amiga/WHDLoad/PETSCIIRobotsInstall/Source/kickfs.s: -------------------------------------------------------------------------------- 1 | ;*--------------------------------------------------------------------------- 2 | ; :Modul. kickfs.s 3 | ; :Contents. filesystem handler for kick emulation under WHDLoad 4 | ; :Author. Wepl, JOTD, Psygore 5 | ; :Version. $Id: kickfs.s 1.26 2020/05/11 00:43:34 wepl Exp wepl $ 6 | ; :History. 17.04.02 separated from kick13.s 7 | ; 02.05.02 _cb_dosRead added 8 | ; 09.05.02 symbols moved to the top for Asm-One/Pro 9 | ; 04.03.03 ACTION_COPY_DIR fixed, wb double click works now 10 | ; deleting of directories works clean 11 | ; changes by JOTD merged 12 | ; 04.04.03 various changes for kick31 13 | ; 11.07.03 relative object names now supported (e.g. "dh0:s//c/info") 14 | ; 06.08.03 sanity check for provided locks added (DEBUG) 15 | ; 09.08.03 ACTION_CURRENT_VOLUME added (JOTD) 16 | ; 01.09.03 ACTION_EXAMINE_FH fixed (Psygore) 17 | ; 29.04.04 ACTION_CREATE_DIR returns ERROR_OBJECT_EXISTS if exists 18 | ; 06.10.04 checks for startup-sequence if not BOOTDOS (JOTD) 19 | ; 17.10.04 set IoErr on Seek on success to be more system conform 20 | ; 26.11.04 set IoErr on Read on success to be more system conform 21 | ; ACTION_SET_COMMENT dummy added 22 | ; 08.02.05 ACTION_ADD_NOTIFY dummy added 23 | ; 04.05.06 fix for startup packet under v34 24 | ; ACTION_SET_DATE dummy added 25 | ; 07.11.07 when DEBUG is set and there is no memory for IOCACHE it 26 | ; faults with _debug5 27 | ; 12.08.09 now properly supports read and write on the same fh when 28 | ; using IOCACHE (flushs cache added), some comments added 29 | ; 16.08.09 flushing IOCACHE wasn't correct handled, fixed 30 | ; 12.01.14 minor optimizations 31 | ; 29.01.14 SNOOPFS added 32 | ; 07.03.18 IOCACHE handling fixed, if a write doesn't fit into the 33 | ; cache after a previous cached write the cache is now 34 | ; flushed before the actual write - this preserves the 35 | ; sequence and avoids possible WHDLoad switches because 36 | ; performing a resload_SaveFileOffset on not yet existing 37 | ; file offset 38 | ; 10.05.20 if Kickstart v37 is present ACTION_FIND_UPDATE now 39 | ; creates a nonexistent file 40 | ; :Requires. - 41 | ; :Copyright. Public Domain 42 | ; :Language. 68000 Assembler 43 | ; :Translator. Barfly 2.9, Asm-Pro 1.16, PhxAss 4.38 44 | ; :To Do. more dos packets (maybe) 45 | ; :Notes. it should be remembered that MODE_READWRITE on dos.Open works 46 | ; different in 1.3 (opens only existing files) and 2.0 (creates 47 | ; files not existing), this makes no diff for kickfs, code is in 48 | ; dos.library 49 | ;---------------------------------------------------------------------------* 50 | 51 | INCLUDE libraries/expansion_lib.i 52 | INCLUDE dos/dosextens.i 53 | INCLUDE dos/filehandler.i 54 | INCLUDE exec/resident.i 55 | INCLUDE libraries/configvars.i 56 | INCLUDE libraries/expansionbase.i 57 | 58 | IFD SNOOPFS 59 | IFLT slv_Version-18 60 | FAIL SNOOPFS require slv_Version >= 18 61 | ENDC 62 | ENDC 63 | 64 | ;---------------------------------------------------------------------------* 65 | ; 66 | ; BootNode 67 | ; 08 LN_TYPE = NT_BOOTNODE 68 | ; 0a LN_NAME -> ConfigDev 69 | ; 10 cd_Rom+er_Type = ERTF_DIAGVALID 70 | ; 1c cd_Rom+er_Reserved0c -> DiagArea 71 | ; 00 da_Config = DAC_CONFIGTIME 72 | ; 06 da_BootPoint -> .bootcode 73 | ; 0e da_SIZEOF 74 | ; 44 cd_SIZEOF 75 | ; 10 bn_DeviceNode -> DeviceNode (exp.MakeDosNode) 76 | * 04 dn_Type = 2 77 | ; 24 dn_SegList -> .seglist 78 | ; 2c dn_SIZEOF 79 | ; 14 bn_SIZEOF 80 | 81 | IFND HD_Cyls 82 | HD_Cyls = 80 83 | ENDC 84 | HD_Surfaces = 2 85 | HD_BlocksPerTrack = 11 86 | HD_NumBlocksRes = 2 87 | HD_NumBlocks = HD_Cyls*HD_Surfaces*HD_BlocksPerTrack-HD_NumBlocksRes 88 | HD_NumBlocksUsed = HD_NumBlocks/2 89 | HD_BytesPerBlock = 512 90 | HD_NumBuffers = 5 91 | 92 | ;file locking is not implemented! no locklist is used 93 | ;fl_Key is used for the filename which makes it impossible to compare two locks for equality! 94 | 95 | STRUCTURE MyLock,fl_SIZEOF 96 | LONG mfl_pos ;position in file 97 | STRUCT mfl_fib,fib_Reserved ;FileInfoBlock 98 | IFD IOCACHE 99 | LONG mfl_cpos ;fileoffset cache points to, -1 means nothing cached 100 | LONG mfl_clen ;amount of dirty data in cache 101 | ;on read cache this is 0 and cache if filled completely 102 | ;on write this is the amount of cached data 103 | ;reads and writes can be mixed, the cache not! 104 | LONG mfl_iocache ;pointer to cache memory 105 | ENDC 106 | LABEL mfl_SIZEOF 107 | 108 | ;---------------------------------------------------------------------------* 109 | 110 | movem.l d0-a6,-(a7) 111 | 112 | IFND BOOTDOS 113 | lea (ss_name,pc),a0 114 | move.l (_resload,pc),a2 115 | jsr (resload_GetFileSize,a2) 116 | tst.l d0 117 | bne .ssok 118 | pea (ss_name,pc) 119 | pea ERROR_OBJECT_NOT_FOUND 120 | pea TDREASON_DOSREAD 121 | jmp (resload_Abort,a2) 122 | .ssok 123 | ENDC 124 | 125 | moveq #ConfigDev_SIZEOF,d0 126 | move.l #MEMF_CLEAR,d1 127 | move.l (4),a6 128 | jsr (_LVOAllocMem,a6) 129 | move.l d0,a5 ;A5 = ConfigDev 130 | bset #ERTB_DIAGVALID,(cd_Rom+er_Type,a5) 131 | lea (.diagarea,pc),a0 132 | move.l a0,(cd_Rom+er_Reserved0c,a5) 133 | 134 | lea (.expansionname,pc),a1 135 | jsr (_LVOOldOpenLibrary,a6) 136 | move.l d0,a4 ;A4 = expansionbase 137 | 138 | lea (.parameterPkt+8,pc),a0 139 | lea (.devicename,pc),a1 140 | move.l a1,-(a0) 141 | lea (.handlername,pc),a1 142 | move.l a1,-(a0) 143 | exg.l a4,a6 144 | jsr (_LVOMakeDosNode,a6) 145 | exg.l a4,a6 146 | move.l d0,a3 ;A3 = DeviceNode 147 | lea (.seglist,pc),a1 148 | move.l a1,d1 149 | lsr.l #2,d1 150 | move.l d1,(dn_SegList,a3) 151 | moveq #-1,d0 152 | move.l d0,(dn_GlobalVec,a3) ;no BCPL shit 153 | 154 | moveq #BootNode_SIZEOF,d0 155 | move.l #MEMF_CLEAR,d1 156 | jsr (_LVOAllocMem,a6) 157 | move.l d0,a1 ;BootNode 158 | move.b #NT_BOOTNODE,(LN_TYPE,a1) 159 | move.l a5,(LN_NAME,a1) ;ConfigDev 160 | move.l a3,(bn_DeviceNode,a1) 161 | 162 | lea (eb_MountList,a4),a0 163 | jsr (_LVOEnqueue,a6) 164 | 165 | movem.l (a7)+,d0-a6 166 | rts 167 | 168 | .diagarea dc.b DAC_CONFIGTIME ;da_Config 169 | dc.b 0 ;da_Flags 170 | dc.w 0 ;da_Size 171 | dc.w 0 ;da_DiagPoint 172 | dc.w .bootcode-.diagarea ;da_BootPoint 173 | dc.w 0 ;da_Name 174 | dc.w 0 ;da_Reserved01 175 | dc.w 0 ;da_Reserved02 176 | 177 | .parameterPkt dc.l 0 ;name of dos handler 178 | dc.l 0 ;name of exec device 179 | dc.l 0 ;unit number for OpenDevice 180 | dc.l 0 ;flags for OpenDevice 181 | dc.l 16 ;de_TableSize count following longwords 182 | dc.l HD_BytesPerBlock/4 ;de_SizeBlock longs per block 183 | dc.l 0 ;de_SecOrg sector start, unused 184 | dc.l HD_Surfaces ;de_Surfaces 185 | dc.l 1 ;de_SectorPerBlock unused 186 | dc.l HD_BlocksPerTrack ;de_BlocksPerTrack 187 | dc.l HD_NumBlocksRes ;de_Reserved reserved blocks 188 | dc.l 0 ;de_PreAlloc unused 189 | dc.l 0 ;de_Interleave 190 | dc.l 0 ;de_LowCyl 191 | dc.l HD_Cyls-1 ;de_HighCyl 192 | dc.l HD_NumBuffers ;de_NumBuffers 193 | dc.l MEMF_PUBLIC ;de_BufMemType 194 | dc.l MAXINT ;de_MaxTransfer 195 | dc.l -1 ;de_Mask 196 | dc.l 0 ;de_BootPri 197 | dc.l ID_DOS_DISK ;de_DosType 198 | ; dc.l ;de_Baud 199 | ; dc.l ;de_Control 200 | ; dc.l ;de_BootBlocks 201 | EVEN 202 | 203 | .bootcode lea (_dosname,pc),a1 204 | jsr (_LVOFindResident,a6) 205 | move.l d0,a0 206 | move.l (RT_INIT,a0),a0 207 | jmp (a0) ;init dos.library 208 | 209 | CNOP 0,4 210 | dc.l 16 ;segment length 211 | .seglist dc.l 0 ;next segment 212 | 213 | ;get own message port 214 | move.l (4),a6 ;A6 = execbase 215 | sub.l a1,a1 216 | jsr (_LVOFindTask,a6) 217 | move.l d0,a1 218 | lea (pr_MsgPort,a1),a5 ;A5 = MsgPort 219 | 220 | ;init volume structure 221 | lea (.volumename,pc),a0 222 | move.l a0,d0 223 | lsr.l #2,d0 224 | move.l d0,-(a7) ;dl_Name 225 | clr.l -(a7) ;dl_unused 226 | move.l #ID_DOS_DISK,-(a7) ;dl_DiskType (is normally 0!) 227 | clr.l -(a7) ;dl_LockList 228 | clr.l -(a7) ;dl_VolumeDate 229 | clr.l -(a7) ;dl_VolumeDate 230 | clr.l -(a7) ;dl_VolumeDate 231 | clr.l -(a7) ;dl_Lock 232 | move.l a5,-(a7) ;dl_Task (MsgPort) 233 | move.l #DLT_VOLUME,-(a7) ;dl_Type 234 | clr.l -(a7) ;dl_Next 235 | move.l a7,d0 236 | lsr.l #2,d0 237 | move.l d0,a3 ;A3 = Volume (BPTR) 238 | ;add to the system 239 | lea (_dosname,pc),a1 240 | jsr (_LVOOldOpenLibrary,a6) 241 | move.l d0,a0 242 | move.l (dl_Root,a0),a0 243 | move.l (rn_Info,a0),a0 244 | add.l a0,a0 245 | add.l a0,a0 246 | move.l (di_DevInfo,a0),(dol_Next,a7) 247 | move.l a3,(di_DevInfo,a0) 248 | 249 | move.l (_resload,pc),a2 ;A2 = resload 250 | 251 | ;fetch and reply startup message 252 | move.l a5,a0 253 | jsr (_LVOWaitPort,a6) 254 | move.l a5,a0 255 | jsr (_LVOGetMsg,a6) 256 | move.l d0,a4 257 | move.l (LN_NAME,a4),a4 ;A4 = DosPacket 258 | IFEQ 1 259 | ;I don't remember that was good for, but it fails under 260 | ;v34 because dp_Arg3 is NULL 261 | move.l (dp_Arg3,a4),d0 ;DeviceNode 262 | beq .nodn ;not present under v34 263 | lsl.l #2,d0 264 | move.l d0,a0 265 | move.l a5,(dn_Task,a0) ;signal: the handler is running 266 | .nodn 267 | ENDC 268 | IFD SNOOPFS 269 | clr.l -(a7) ;place for function infos 270 | ENDC 271 | bra .reply1true 272 | 273 | ;loop on receiving new packets 274 | .mainloop 275 | IFD SNOOPFS 276 | ;log the message 277 | move.w (a7),d2 ;skip startup package 278 | beq .skipsnoop 279 | move.l (dp_Arg5,a4),-(a7) 280 | move.l (dp_Arg4,a4),-(a7) 281 | move.l (dp_Arg3,a4),-(a7) 282 | move.l (dp_Arg2,a4),-(a7) 283 | move.l (dp_Arg1,a4),-(a7) 284 | move.l (dp_Res2,a4),-(a7) 285 | move.l (dp_Res1,a4),-(a7) 286 | pea (.snoopfshead,pc) 287 | lea (.action,pc,d2.w),a0 288 | jsr (resload_Log,a2) 289 | add.w #8*4,a7 290 | .skipsnoop 291 | ENDC 292 | move.l a5,a0 293 | jsr (_LVOWaitPort,a6) 294 | move.l a5,a0 295 | jsr (_LVOGetMsg,a6) 296 | move.l d0,a4 297 | move.l (LN_NAME,a4),a4 ;A4 = DosPacket 298 | 299 | ;find and call appropriate action 300 | moveq #0,d0 301 | move.l (dp_Type,a4),d4 302 | lea (.action,pc),a0 303 | IFND SNOOPFS 304 | .next movem.w (a0)+,d0-d1 305 | ELSE 306 | .next movem.w (a0)+,d0-d2 307 | move.w d2,(a7) ;save 308 | ENDC 309 | IFD DEBUG 310 | tst.l d0 311 | beq _debug1 ;unknown packet 312 | ENDC 313 | cmp.w d0,d4 ;this should be cmp.l 314 | bne .next 315 | jmp (.action,pc,d1.w) 316 | 317 | KFSDPKT MACRO 318 | dc.w ACTION_\1 319 | dc.w .a_\2-.action 320 | IFD SNOOPFS 321 | dc.w .f_\2-.action 322 | ENDC 323 | ENDM 324 | 325 | CNOP 0,4 326 | .action KFSDPKT CURRENT_VOLUME,current_volume ;7 7 327 | KFSDPKT LOCATE_OBJECT,locate_object ;8 8 328 | KFSDPKT FREE_LOCK,free_lock ;f 15 329 | KFSDPKT DELETE_OBJECT,delete_object ;10 16 330 | KFSDPKT COPY_DIR,copy_dir ;13 19 331 | KFSDPKT SET_PROTECT,set_protect ;15 21 332 | KFSDPKT CREATE_DIR,create_dir ;16 22 333 | KFSDPKT EXAMINE_OBJECT,examine_object ;17 23 334 | KFSDPKT EXAMINE_NEXT,examine_next ;18 24 335 | KFSDPKT DISK_INFO,disk_info ;19 25 336 | KFSDPKT INFO,info ;1a 26 337 | KFSDPKT FLUSH,flush ;1b 27 338 | KFSDPKT SET_COMMENT,set_comment ;1c 28 339 | KFSDPKT PARENT,parent ;1d 29 340 | KFSDPKT INHIBIT,inhibit ;1f 31 341 | KFSDPKT SET_DATE,set_date ;22 34 342 | KFSDPKT READ,read ;52 82 343 | KFSDPKT WRITE,write ;57 87 344 | KFSDPKT FINDUPDATE,findupdate ;3ec 1004 345 | KFSDPKT FINDINPUT,findinput ;3ed 1005 346 | KFSDPKT FINDOUTPUT,findoutput ;3ee 1006 347 | KFSDPKT END,end ;3ef 1007 348 | KFSDPKT SEEK,seek ;3f0 1008 349 | IFGT KICKVERSION-36 350 | KFSDPKT SAME_LOCK,same_lock ;28 40 351 | KFSDPKT FH_FROM_LOCK,fh_from_lock ;402 1026 352 | KFSDPKT IS_FILESYSTEM,is_filesystem ;403 1027 353 | KFSDPKT EXAMINE_ALL,examine_all ;409 1033 354 | KFSDPKT EXAMINE_FH,examine_fh ;40A 1034 355 | KFSDPKT ADD_NOTIFY,add_notify ;1001 4097 356 | ENDC 357 | dc.w 0 358 | 359 | ;--------------- 360 | ; reply dos-packet 361 | ; IN: D0 = res1 362 | ; D1 = res2 363 | 364 | .reply2 move.l d1,(dp_Res2,a4) 365 | 366 | ;--------------- 367 | ; reply dos-packet 368 | ; IN: D0 = res1 369 | 370 | .reply1 move.l d0,(dp_Res1,a4) 371 | move.l (dp_Port,a4),a0 372 | move.l (dp_Link,a4),a1 373 | move.l a5,(dp_Port,a4) 374 | jsr (_LVOPutMsg,a6) 375 | bra .mainloop 376 | 377 | ; conventions for action functions: 378 | ; IN: a2 = resload 379 | ; a3 = BPTR volume node 380 | ; a4 = packet 381 | ; a5 = MsgPort 382 | ; a6 = execbase 383 | 384 | ;--------------- 385 | 386 | .a_current_volume 387 | move.l a3,d0 ;volume 388 | moveq #0,d1 ;unit number 389 | bra .reply2 390 | 391 | ;--------------- 392 | 393 | .a_locate_object 394 | bsr .getarg1 ;lock 395 | move.l d7,d0 396 | bsr .getarg2 ;name 397 | move.l d7,d1 398 | move.l (dp_Arg3,a4),d2 ;mode 399 | bsr .lock 400 | lsr.l #2,d0 ;APTR > BPTR 401 | bne .reply1 402 | bra .reply2 403 | 404 | ;--------------- 405 | 406 | .a_free_lock bsr .getarg1 407 | move.l d7,d0 408 | bsr .unlock 409 | bra .reply1true 410 | 411 | ;--------------- 412 | 413 | .a_delete_object 414 | bsr .getarg1 ;lock 415 | move.l d7,d0 416 | bsr .getarg2 ;name 417 | move.l d7,d1 418 | move.l #ACCESS_READ,d2 419 | bsr .lock 420 | move.l d0,d7 ;d7 = new lock 421 | beq .reply2 422 | move.l d0,a0 423 | tst.l (mfl_fib+fib_DirEntryType,a0) 424 | bmi .delete_do 425 | ;a directory 426 | lea (mfl_fib,a0),a0 427 | jsr (resload_ExNext,a2) 428 | tst.l d0 429 | bne .delete_dirnotempty 430 | move.l d7,a0 431 | .delete_do move.l (fl_Key,a0),a0 432 | jsr (resload_DeleteFile,a2) 433 | move.l d7,d0 434 | bsr .unlock 435 | bra .reply1true 436 | 437 | .delete_dirnotempty 438 | move.l d7,d0 439 | bsr .unlock 440 | moveq #DOSFALSE,d0 441 | move.l #ERROR_DIRECTORY_NOT_EMPTY,d1 442 | bra .reply2 443 | 444 | ;--------------- 445 | 446 | .a_copy_dir bsr .getarg1 447 | IFD DEBUG 448 | beq _debug2 449 | ENDC 450 | ;copy name 451 | move.l d7,a0 ;a0 = APTR lock 452 | IFD DEBUG 453 | cmp.l (fl_Task,a0),a5 454 | bne _debug4 455 | ENDC 456 | move.l (fl_Key,a0),a0 ;name 457 | move.l -(a0),d0 458 | moveq #0,d1 459 | jsr (_LVOAllocMem,a6) 460 | move.l d0,d2 ;d2 = new name 461 | beq .copy_dir_nm 462 | move.l d7,a0 463 | move.l (fl_Key,a0),a0 464 | move.l d2,a1 465 | move.l -(a0),d0 ;length 466 | .copy_dir_cpy move.l (a0)+,(a1)+ 467 | subq.l #4,d0 468 | bhi .copy_dir_cpy 469 | ;copy lock 470 | move.l #mfl_SIZEOF,d0 471 | move.l #MEMF_CLEAR,d1 472 | jsr (_LVOAllocMem,a6) 473 | tst.l d0 474 | beq .copy_dir_nm2 475 | ;fill lock structure 476 | move.l d7,a0 477 | move.l d0,a1 478 | move.l (a0)+,(a1)+ ;fl_Link 479 | addq.l #4,d2 480 | move.l d2,(a1)+ ;fl_Key (name) 481 | addq.l #4,a0 482 | move.l (a0)+,(a1)+ ;fl_Access 483 | move.l (a0)+,(a1)+ ;fl_Task (MsgPort) 484 | move.l (a0)+,(a1)+ ;fl_Volume 485 | lsr.l #2,d0 ;lock 486 | bra .reply1 487 | 488 | .copy_dir_nm2 move.l d2,a1 489 | move.l (a1),d0 490 | jsr (_LVOFreeMem,a6) 491 | .copy_dir_nm moveq #DOSFALSE,d0 492 | move.l #ERROR_NO_FREE_STORE,d1 493 | bra .reply2 494 | 495 | ;--------------- 496 | 497 | .a_create_dir bsr .getarg1 498 | move.l d7,d0 ;APTR lock 499 | bsr .getarg2 500 | move.l d7,d1 ;BSTR name 501 | moveq #ACCESS_READ,d2 ;mode 502 | bsr .lock 503 | tst.l d0 504 | beq .createdir_full 505 | bsr .unlock 506 | moveq #0,d0 507 | move.l #ERROR_OBJECT_EXISTS,d1 508 | bra .reply2 509 | .createdir_full move.l #ERROR_DISK_FULL,d1 510 | bra .reply2 511 | 512 | ;--------------- 513 | 514 | IFGT KICKVERSION-36 515 | .a_examine_fh move.l (dp_Arg1,a4),a0 ;lock 516 | bra .a_examine 517 | ENDC 518 | 519 | .a_examine_object 520 | bsr .getarg1 521 | move.l d7,a0 ;a0 = APTR lock 522 | 523 | .a_examine bsr .getarg2 ;d7 = APTR fib 524 | move.l a0,d0 525 | beq .examine_root 526 | ;copy whdload's examine result 527 | add.w #mfl_fib,a0 528 | move.l d7,a1 529 | moveq #fib_Reserved/4-1,d0 530 | .examine_fib move.l (a0)+,(a1)+ 531 | dbf d0,.examine_fib 532 | ;adjust 533 | .examine_adj 534 | ;convert CSTR -> BSTR 535 | move.l d7,a1 536 | lea (fib_FileName,a1),a0 537 | bsr .bstr 538 | lea (fib_Comment,a1),a0 539 | bsr .bstr 540 | ;return 541 | bra .reply1true 542 | 543 | ;special handling of NULL lock 544 | .examine_root clr.l -(a7) 545 | move.l a7,a0 546 | move.l d7,a1 547 | jsr (resload_Examine,a2) 548 | addq.l #4,a7 549 | lea (.volumename+1,pc),a0 ;CPTR 550 | move.l d7,a1 551 | add.w #fib_FileName,a1 552 | .examine_root2 move.b (a0)+,(a1)+ 553 | bne .examine_root2 554 | bra .examine_adj 555 | 556 | ;--------------- 557 | 558 | .a_examine_next bsr .getarg2 559 | move.l d7,a0 ;a0 = APTR fib 560 | jsr (resload_ExNext,a2) 561 | move.l d7,a1 562 | ;convert CSTR -> BSTR 563 | lea (fib_FileName,a1),a0 564 | bsr .bstr 565 | lea (fib_Comment,a1),a0 566 | bsr .bstr 567 | bra .reply2 568 | 569 | ;--------------- 570 | 571 | .a_info bsr .getarg2 572 | bra .a_disk_info_1 573 | 574 | ;--------------- 575 | 576 | .a_disk_info bsr .getarg1 577 | .a_disk_info_1 move.l d7,a0 578 | clr.l (a0)+ ;id_NumSoftErrors 579 | clr.l (a0)+ ;id_UnitNumber 580 | move.l #ID_VALIDATED,(a0)+ ;id_DiskState 581 | move.l #HD_NumBlocks,(a0)+ ;id_NumBlocks 582 | move.l #HD_NumBlocksUsed,(a0)+ ;id_NumBlocksUsed 583 | move.l #HD_BytesPerBlock,(a0)+ ;id_BytesPerBlock 584 | move.l #ID_DOS_DISK,(a0)+ ;id_DiskType 585 | move.l a3,(a0)+ ;id_VolumeNode 586 | clr.l (a0)+ ;id_InUse 587 | 588 | ;--------------- 589 | 590 | .a_is_filesystem 591 | .a_set_protect 592 | .a_set_comment 593 | .a_set_date 594 | .a_flush 595 | .a_inhibit 596 | .reply1true moveq #DOSTRUE,d0 597 | bra .reply1 598 | 599 | ;--------------- 600 | 601 | .a_parent bsr .getarg1 602 | beq .parent_root 603 | move.l d7,a0 ;d7 = lock 604 | IFD DEBUG 605 | cmp.l (fl_Task,a0),a5 606 | bne _debug4 607 | ENDC 608 | move.l (fl_Key,a0),a0 609 | tst.b (a0) 610 | beq .parent_root 611 | ;get string length 612 | moveq #-1,d0 613 | .parent_strlen addq.l #1,d0 614 | tst.b (a0)+ 615 | bne .parent_strlen ;d0 = strlen 616 | ;search for "/" 617 | move.l d7,a0 618 | move.l (fl_Key,a0),a0 619 | lea (a0,d0.l),a1 620 | .parent_search cmp.b #"/",-(a1) 621 | beq .parent_slash 622 | cmp.l a0,a1 623 | bne .parent_search 624 | ;no slash found, so we are locking root 625 | ;lock the parent directory 626 | .parent_slash 627 | ;build temporary bstr 628 | move.l a1,d0 629 | sub.l a0,d0 ;length 630 | move.l d0,d3 631 | addq.l #4,d3 ;+1 and align4 632 | and.b #$fc,d3 633 | sub.l d3,a7 634 | move.l a7,a1 635 | move.b d0,(a1)+ 636 | .parent_cpy move.b (a0)+,(a1)+ 637 | subq.l #1,d0 638 | bhi .parent_cpy 639 | ;lock it 640 | moveq #0,d0 ;lock 641 | move.l a7,d1 ;name 642 | move.l #ACCESS_READ,d2 ;mode 643 | bsr .lock 644 | add.l d3,a7 645 | lsr.l #2,d0 ;APTR > BPTR 646 | bne .reply1 647 | bra .reply2 648 | ;that is a special case! 649 | .parent_root moveq #0,d0 650 | moveq #0,d1 651 | bra .reply2 652 | 653 | ;--------------- 654 | 655 | IFGT KICKVERSION-36 656 | .a_same_lock bsr .getarg1 657 | move.l d7,a0 658 | bsr .getarg2 659 | move.l d7,a1 660 | move.l a0,d0 661 | beq .samelock_zero 662 | IFD DEBUG 663 | cmp.l (fl_Task,a0),a5 664 | bne _debug4 665 | ENDC 666 | move.l (fl_Key,a0),a0 667 | tst.b (a0) 668 | beq .samelock_zero 669 | move.l a1,d0 670 | beq .samelock_neq 671 | IFD DEBUG 672 | cmp.l (fl_Task,a1),a5 673 | bne _debug4 674 | ENDC 675 | move.l (fl_Key,a1),a1 676 | .samelock_cmp move.b (a0)+,d0 677 | cmp.b (a1)+,d0 678 | bne .samelock_neq 679 | tst.b d0 680 | bne .samelock_cmp 681 | .samelock_equ bra .reply1true 682 | 683 | .samelock_zero move.l a1,d0 684 | beq .samelock_equ 685 | move.l (fl_Key,a1),a1 686 | tst.b (a1) 687 | beq .samelock_equ 688 | .samelock_neq moveq #0,d0 689 | moveq #0,d1 690 | bra .reply2 691 | ENDC 692 | 693 | ;--------------- 694 | 695 | .a_read move.l (dp_Arg1,a4),a0 ;a0 = APTR lock 696 | IFD DEBUG 697 | cmp.l (fl_Task,a0),a5 698 | bne _debug4 699 | ENDC 700 | move.l (dp_Arg3,a4),d3 ;d3 = readsize 701 | IFD IOCACHE 702 | moveq #0,d4 ;d4 = readcachesize 703 | bsr .flush_write_cache ;cannot mix read/write, sets a0 again 704 | ENDC 705 | move.l (mfl_pos,a0),d5 ;d5 = pos 706 | ;correct readsize if necessary 707 | move.l (mfl_fib+fib_Size,a0),d2 708 | sub.l d5,d2 ;d2 = bytes left in file 709 | cmp.l d2,d3 710 | bls .read_ok 711 | move.l d2,d3 ;d3 = readsize 712 | .read_ok tst.l d3 713 | beq .read_end ;eof 714 | add.l d3,(mfl_pos,a0) 715 | IFD BOOTDOS 716 | ;special files 717 | move.l (fl_Key,a0),a0 ;name 718 | bsr .specialfile 719 | tst.l d0 720 | beq .read_nospec 721 | move.l d0,a0 722 | add.l d5,a0 ;source 723 | move.l (dp_Arg2,a4),a1 ;destination 724 | move.l d3,d0 725 | .read_spec move.b (a0)+,(a1)+ 726 | subq.l #1,d0 727 | bne .read_spec 728 | bra .read_end 729 | .read_nospec move.l (dp_Arg1,a4),a0 730 | ENDC 731 | IFND IOCACHE 732 | ;read direct 733 | move.l d3,d0 ;length 734 | move.l d5,d1 ;offset 735 | move.l (fl_Key,a0),a0 ;name 736 | move.l (dp_Arg2,a4),a1 ;buffer 737 | jsr (resload_LoadFileOffset,a2) 738 | ;finish 739 | .read_end move.l d3,d0 ;bytes read 740 | moveq #0,d1 ;no error 741 | IFD CBDOSREAD 742 | movem.l d0-a6,-(a7) 743 | move.l (dp_Arg1,a4),a0 744 | move.l (mfl_pos,a0),d1 745 | sub.l d0,d1 ;file pos 746 | move.l (fl_Key,a0),a0 ;name 747 | move.l (dp_Arg2,a4),a1 ;buffer 748 | bsr _cb_dosRead 749 | movem.l (a7)+,d0-a6 750 | ENDC 751 | bra .reply2 752 | ELSE 753 | move.l #IOCACHE,d7 ;d7 = IOCACHE 754 | move.l (mfl_cpos,a0),d6 ;d6 = cachepos 755 | bmi .read_1 ;skip if nothing cached yet 756 | ;try from cache 757 | cmp.l d5,d6 ;pos to read higher than in cache? 758 | bhi .read_1 759 | move.l d7,d0 760 | add.l d6,d0 761 | sub.l d5,d0 ;pos to read lower then end in cache? 762 | bls .read_1 763 | move.l d0,d4 ;d4 = readcachesize 764 | cmp.l d4,d3 765 | bhi .read_2 766 | move.l d3,d4 ;fully from cache 767 | .read_2 move.l (mfl_iocache,a0),a0 768 | add.l d5,a0 769 | sub.l d6,a0 ;source 770 | move.l (dp_Arg2,a4),a1 ;destination 771 | move.l d4,d0 772 | .read_3 move.b (a0)+,(a1)+ 773 | subq.l #1,d0 774 | bne .read_3 775 | add.l d4,d5 776 | sub.l d4,d2 777 | sub.l d4,d3 778 | beq .read_end 779 | ;decide if read through cache or direct 780 | .read_1 cmp.l d7,d3 ;fits remaining data to read into cache? 781 | blo .read_c 782 | ;read direct 783 | .read_d move.l d3,d0 ;length 784 | move.l d5,d1 ;offset 785 | move.l (dp_Arg1,a4),a0 786 | move.l (fl_Key,a0),a0 ;name 787 | move.l (dp_Arg2,a4),a1 ;buffer 788 | add.l d4,a1 789 | jsr (resload_LoadFileOffset,a2) 790 | bra .read_end 791 | ;read through cache 792 | .read_c 793 | ;get memory if necessary 794 | move.l (dp_Arg1,a4),a0 795 | move.l (mfl_iocache,a0),d0 796 | bne .read_c1 797 | move.l d7,d0 798 | moveq #MEMF_ANY,d1 799 | jsr (_LVOAllocMem,a6) 800 | move.l (dp_Arg1,a4),a0 801 | move.l d0,(mfl_iocache,a0) 802 | IFD DEBUG 803 | beq _debug5 804 | ELSE 805 | beq .read_d 806 | ENDC 807 | ;read into cache 808 | .read_c1 move.l d0,a1 ;cache 809 | move.l (mfl_fib+fib_Size,a0),d0 810 | sub.l d5,d0 ;length 811 | cmp.l d7,d0 812 | bls .read_c2 813 | move.l d7,d0 ;length 814 | .read_c2 move.l d5,d1 ;offset 815 | move.l (fl_Key,a0),a0 ;name 816 | jsr (resload_LoadFileOffset,a2) 817 | move.l (dp_Arg1,a4),a0 818 | move.l d5,(mfl_cpos,a0) 819 | ;copy from cache 820 | move.l (mfl_iocache,a0),a0 ;source 821 | move.l (dp_Arg2,a4),a1 822 | add.l d4,a1 ;destination 823 | move.l d3,d0 824 | .read_c3 move.b (a0)+,(a1)+ 825 | subq.l #1,d0 826 | bne .read_c3 827 | ;finish 828 | .read_end move.l d3,d0 829 | add.l d4,d0 830 | moveq #0,d1 ;no error 831 | IFD CBDOSREAD 832 | movem.l d0-a6,-(a7) 833 | move.l (dp_Arg1,a4),a0 834 | move.l (mfl_pos,a0),d1 835 | sub.l d0,d1 ;file pos 836 | move.l (fl_Key,a0),a0 ;name 837 | move.l (dp_Arg2,a4),a1 ;buffer 838 | bsr _cb_dosRead 839 | movem.l (a7)+,d0-a6 840 | ENDC 841 | bra .reply2 842 | ENDC 843 | 844 | ;--------------- 845 | 846 | .a_write move.l (dp_Arg1,a4),a0 ;APTR lock 847 | IFD DEBUG 848 | cmp.l (fl_Task,a0),a5 849 | bne _debug4 850 | ENDC 851 | IFND IOCACHE 852 | move.l (dp_Arg3,a4),d0 ;len 853 | beq .write_end 854 | move.l (mfl_pos,a0),d1 ;offset 855 | move.l d1,d2 856 | add.l d0,d2 857 | move.l d2,(mfl_pos,a0) ;new position 858 | cmp.l (mfl_fib+fib_Size,a0),d2 859 | bls .write_inside 860 | move.l d2,(mfl_fib+fib_Size,a0) ;new length 861 | .write_inside move.l (fl_Key,a0),a0 ;name 862 | move.l (dp_Arg2,a4),a1 ;buffer 863 | jsr (resload_SaveFileOffset,a2) 864 | .write_end move.l (dp_Arg3,a4),d0 ;bytes written 865 | bra .reply1 866 | ELSE 867 | ;set new pos and correct size if necessary 868 | move.l #IOCACHE,d4 ;d4 = IOCACHE 869 | move.l (dp_Arg2,a4),d5 ;d5 = buffer 870 | move.l (dp_Arg3,a4),d6 ;d6 = len 871 | beq .write_end 872 | move.l (mfl_pos,a0),d7 ;d7 = offset before write 873 | move.l d6,d0 874 | add.l d7,d0 875 | move.l d0,(mfl_pos,a0) ;new position 876 | cmp.l (mfl_fib+fib_Size,a0),d0 877 | bls .write_inside 878 | move.l d0,(mfl_fib+fib_Size,a0) ;new length 879 | .write_inside 880 | ;is there already a write cache? 881 | move.l (mfl_clen,a0),d0 882 | bne .write_chkapp 883 | ;invalidate possible read cache 884 | moveq #-1,d0 885 | move.l d0,(mfl_cpos,a0) 886 | bra .write_checkfit 887 | ;matches the offset the end of the last cached write? 888 | .write_chkapp add.l (mfl_cpos,a0),d0 889 | cmp.l d0,d7 890 | bne .write_flush 891 | ;does fit existing cache + new write in 2*IOCACHE 892 | move.l (mfl_clen,a0),d0 893 | add.l d6,d0 894 | move.l d4,d1 895 | add.l d4,d1 896 | cmp.l d1,d0 897 | blo .write_fill 898 | ;flush existing write cache 899 | .write_flush bsr .flush_write_cache 900 | ;check if write fits into the cache 901 | .write_checkfit cmp.l d6,d4 902 | bls .write_direct 903 | ;fill cache 904 | .write_fill 905 | ;get memory if necessary 906 | move.l (mfl_iocache,a0),d0 907 | bne .write_memok 908 | move.l d4,d0 909 | moveq #MEMF_ANY,d1 910 | jsr (_LVOAllocMem,a6) 911 | move.l (dp_Arg1,a4),a0 ;lock 912 | move.l d0,(mfl_iocache,a0) 913 | IFD DEBUG 914 | beq _debug5 915 | ELSE 916 | beq .write_direct 917 | ENDC 918 | .write_memok move.l d0,a1 919 | ;determine bytes to copy 920 | move.l d4,d0 ;IOCACHE 921 | sub.l (mfl_clen,a0),d0 922 | cmp.l d6,d0 ;len 923 | blo .write_fill_len 924 | move.l d6,d0 925 | .write_fill_len 926 | ;copy to cache 927 | tst.l (mfl_cpos,a0) 928 | bpl .write_cpos_set 929 | move.l d7,(mfl_cpos,a0) ;new position 930 | .write_cpos_set add.l (mfl_clen,a0),a1 931 | add.l d0,(mfl_clen,a0) ;new length 932 | sub.l d0,d6 ;len 933 | add.l d0,d7 ;position 934 | exg.l d5,a0 ;lock<>buffer 935 | .write_cpy move.b (a0)+,(a1)+ 936 | subq.l #1,d0 937 | bne .write_cpy 938 | exg.l a0,d5 ;lock<>buffer 939 | tst.l d6 ;all written? 940 | beq .write_end 941 | bra .write_flush ;loop for 2nd cycle 942 | ;write without cache 943 | .write_direct move.l d6,d0 ;len 944 | move.l d7,d1 ;offset 945 | move.l (fl_Key,a0),a0 ;name 946 | move.l d5,a1 ;buffer 947 | jsr (resload_SaveFileOffset,a2) 948 | .write_end move.l (dp_Arg3,a4),d0 ;bytes written 949 | bra .reply1 950 | ENDC 951 | 952 | ;--------------- lock delete create 953 | ; MODE_READWRITE - UPDATE 1.3 WRITE no no 954 | ; MODE_READWRITE - UPDATE 2.0 READ no yes 955 | ; MODE_OLDFILE - INPUT READ no no 956 | ; MODE_NEWFILE - OUTPUT WRITE yes yes 957 | 958 | IFLT KICKVERSION-36 959 | .a_findupdate moveq #ACCESS_WRITE,d2 ;mode 960 | bra .a_findall 961 | ELSE 962 | .a_findupdate moveq #ACCESS_READ,d2 ;mode 963 | ;check exist and lock it 964 | bsr .getarg2 965 | move.l d7,d0 ;APTR lock 966 | bsr .getarg3 967 | move.l d7,d1 ;BSTR name 968 | bsr .lock 969 | tst.l d0 ;APTR lock 970 | bne .a_find_locked 971 | bra .a_findoutput 972 | ENDC 973 | 974 | .a_findinput moveq #ACCESS_READ,d2 ;mode 975 | .a_findall 976 | ;check exist and lock it 977 | bsr .getarg2 978 | move.l d7,d0 ;APTR lock 979 | bsr .getarg3 980 | move.l d7,d1 ;BSTR name 981 | bsr .lock 982 | tst.l d0 ;APTR lock 983 | beq .reply2 984 | ;init fh 985 | .a_find_locked bsr .getarg1 986 | move.l d7,a0 ;fh 987 | move.l d0,(fh_Arg1,a0) ;using the lock we refer the filename later 988 | ;log the lock to allow check for Open/Close pair 989 | IFD SNOOPFS 990 | move.l (dp_Arg3,a4),-(a7) 991 | move.l (dp_Arg2,a4),-(a7) 992 | move.l (dp_Arg1,a4),-(a7) 993 | move.l d0,-(a7) 994 | pea (.snoopfshead,pc) 995 | lea (.f_find,pc),a0 996 | jsr (resload_Log,a2) 997 | add.w #5*4,a7 998 | ENDC 999 | ;return 1000 | bra .reply1true 1001 | 1002 | .a_findoutput bsr .getarg2 1003 | move.l d7,d0 ;APTR lock 1004 | bsr .getarg3 1005 | move.l d7,d1 ;BSTR name 1006 | bsr .buildname 1007 | move.l d0,d2 ;d2 = name 1008 | beq .reply2 1009 | ;create an empty file 1010 | move.l d2,a0 1011 | sub.l a1,a1 1012 | moveq #0,d0 1013 | jsr (resload_SaveFile,a2) 1014 | ;free the name 1015 | move.l d2,a1 1016 | move.l -(a1),d0 1017 | jsr (_LVOFreeMem,a6) 1018 | IFLT KICKVERSION-36 1019 | bra .a_findupdate 1020 | ELSE 1021 | bra .a_findinput 1022 | ENDC 1023 | 1024 | ;--------------- 1025 | 1026 | .a_end 1027 | IFD DEBUG 1028 | move.l (dp_Arg1,a4),a0 ;APTR lock 1029 | cmp.l (fl_Task,a0),a5 1030 | bne _debug4 1031 | ENDC 1032 | IFD IOCACHE 1033 | bsr .flush_write_cache 1034 | ENDC 1035 | move.l (dp_Arg1,a4),d0 ;APTR lock 1036 | bsr .unlock 1037 | bra .reply1true 1038 | 1039 | ;--------------- 1040 | 1041 | IFD IOCACHE 1042 | ;dp_Arg1 must be the filelock 1043 | ;a read cache remains intact! 1044 | ;must return a0 = APTR lock (dp_Arg1) 1045 | .flush_write_cache 1046 | move.l (dp_Arg1,a4),a0 ;lock 1047 | move.l (mfl_clen,a0),d0 ;len (only set on write cache) 1048 | beq .fwc_nowcache 1049 | move.l (mfl_cpos,a0),d1 ;offset 1050 | move.l (mfl_iocache,a0),a1 ;buffer 1051 | move.l (fl_Key,a0),a0 ;name 1052 | jsr (resload_SaveFileOffset,a2) 1053 | move.l (dp_Arg1,a4),a0 ;lock 1054 | clr.l (mfl_clen,a0) 1055 | moveq #-1,d0 1056 | move.l d0,(mfl_cpos,a0) 1057 | .fwc_nowcache rts 1058 | ENDC 1059 | 1060 | ;--------------- 1061 | 1062 | .a_seek move.l (dp_Arg1,a4),a0 ;APTR lock 1063 | move.l (dp_Arg2,a4),d2 ;offset 1064 | move.l (dp_Arg3,a4),d1 ;mode 1065 | ;calculate new position 1066 | beq .seek_cur 1067 | bmi .seek_beg 1068 | .seek_end add.l (mfl_fib+fib_Size,a0),d2 1069 | bra .seek_chk 1070 | .seek_cur add.l (mfl_pos,a0),d2 1071 | .seek_beg 1072 | .seek_chk 1073 | ;validate new position 1074 | cmp.l (mfl_fib+fib_Size,a0),d2 1075 | bhi .seek_err 1076 | ;set new 1077 | move.l (mfl_pos,a0),d0 ;return old position 1078 | move.l d2,(mfl_pos,a0) 1079 | moveq #0,d1 1080 | bra .reply2 1081 | .seek_err move.l #-1,d0 1082 | move.l #ERROR_SEEK_ERROR,d1 1083 | bra .reply2 1084 | 1085 | ;--------------- 1086 | 1087 | IFGT KICKVERSION-36 1088 | .a_fh_from_lock bsr .getarg1 ;handle 1089 | move.l d7,a0 1090 | bsr .getarg2 ;lock 1091 | move.l d7,(fh_Arg1,a0) ;using the lock we refer the filename later 1092 | bra .reply1true 1093 | ENDC 1094 | 1095 | ;--------------- 1096 | 1097 | IFGT KICKVERSION-36 1098 | .a_add_notify 1099 | .a_examine_all moveq #DOSFALSE,d0 1100 | move.l #ERROR_ACTION_NOT_KNOWN,d1 1101 | bra .reply2 1102 | ENDC 1103 | 1104 | ;--------------- 1105 | ; these functions get the respective arg converted from a BPTR to a APTR in D7 1106 | 1107 | .getarg1 move.l (dp_Arg1,a4),d7 1108 | lsl.l #2,d7 1109 | rts 1110 | .getarg2 move.l (dp_Arg2,a4),d7 1111 | lsl.l #2,d7 1112 | rts 1113 | .getarg3 move.l (dp_Arg3,a4),d7 1114 | lsl.l #2,d7 1115 | rts 1116 | 1117 | ;--------------- 1118 | ; convert c-string into bcpl-string 1119 | ; IN: a0 = CSTR 1120 | ; OUT: - 1121 | 1122 | .bstr movem.l d0-d2,-(a7) 1123 | moveq #-1,d0 1124 | move.b (a0)+,d2 1125 | .bstr_1 addq.l #1,d0 1126 | move.b d2,d1 1127 | move.b (a0),d2 1128 | move.b d1,(a0)+ 1129 | bne .bstr_1 1130 | sub.l d0,a0 1131 | move.b d0,(-2,a0) 1132 | movem.l (a7)+,d0-d2 1133 | rts 1134 | 1135 | ;--------------- 1136 | ; lock a disk object 1137 | ; IN: d0 = APTR lock 1138 | ; d1 = BSTR name 1139 | ; d2 = LONG mode 1140 | ; OUT: d0 = APTR lock 1141 | ; d1 = LONG errcode 1142 | 1143 | .lock movem.l d4/a4,-(a7) 1144 | ;get name 1145 | bsr .buildname 1146 | tst.l d0 1147 | beq .lock_quit 1148 | move.l d0,d4 ;D4 = name 1149 | ;get memory for lock 1150 | move.l #mfl_SIZEOF,d0 1151 | move.l #MEMF_CLEAR,d1 1152 | jsr (_LVOAllocMem,a6) 1153 | tst.l d0 1154 | beq .lock_nomem 1155 | move.l d0,a4 ;A4 = myfilelock 1156 | ;special 1157 | IFD BOOTDOS 1158 | move.l d4,a0 1159 | bsr .specialfile 1160 | tst.l d0 1161 | beq .lock_nospec 1162 | move.l #ST_FILE,(mfl_fib+fib_DirEntryType,a4) 1163 | move.l d1,(mfl_fib+fib_Size,a4) 1164 | bra .lock_spec 1165 | .lock_nospec 1166 | ENDC 1167 | ;examine 1168 | move.l d4,a0 ;name 1169 | lea (mfl_fib,a4),a1 ;fib 1170 | jsr (resload_Examine,a2) 1171 | tst.l d0 1172 | beq .lock_notfound 1173 | .lock_spec 1174 | ;set return values 1175 | move.l a4,d0 1176 | moveq #0,d1 1177 | ;fill lock structure 1178 | IFD IOCACHE 1179 | subq.l #1,(mfl_cpos,a4) ;nothing cached yet 1180 | ENDC 1181 | addq.l #4,a4 ;fl_Link 1182 | move.l d4,(a4)+ ;fl_Key (name) 1183 | move.l d2,(a4)+ ;fl_Access 1184 | move.l a5,(a4)+ ;fl_Task (MsgPort) 1185 | move.l a3,(a4)+ ;fl_Volume 1186 | .lock_quit movem.l (a7)+,d4/a4 1187 | .rts rts 1188 | .lock_notfound move.l #mfl_SIZEOF,d0 1189 | move.l a4,a1 1190 | jsr (_LVOFreeMem,a6) 1191 | pea ERROR_OBJECT_NOT_FOUND 1192 | bra .lock_err 1193 | .lock_nomem pea ERROR_NO_FREE_STORE 1194 | ;on error free the name 1195 | .lock_err move.l d4,a1 1196 | move.l -(a1),d0 1197 | jsr (_LVOFreeMem,a6) 1198 | move.l (a7)+,d1 1199 | moveq #DOSFALSE,d0 1200 | bra .lock_quit 1201 | 1202 | ;--------------- 1203 | ; free a lock 1204 | ; IN: d0 = APTR lock 1205 | ; OUT: - 1206 | 1207 | .unlock tst.l d0 1208 | beq .rts 1209 | move.l d0,a1 1210 | IFD DEBUG 1211 | cmp.l (fl_Task,a1),a5 1212 | bne _debug4 1213 | clr.l (fl_Task,a1) 1214 | ENDC 1215 | move.l (fl_Key,a1),-(a7) ;name 1216 | IFD IOCACHE 1217 | move.l (mfl_iocache,a1),-(a7) 1218 | ENDC 1219 | move.l #mfl_SIZEOF,d0 1220 | jsr (_LVOFreeMem,a6) 1221 | IFD IOCACHE 1222 | move.l (a7)+,d0 1223 | beq .unlock1 1224 | move.l d0,a1 1225 | move.l #IOCACHE,d0 1226 | jsr (_LVOFreeMem,a6) 1227 | .unlock1 1228 | ENDC 1229 | move.l (a7)+,a1 1230 | move.l -(a1),d0 1231 | jmp (_LVOFreeMem,a6) 1232 | 1233 | ;--------------- 1234 | ; build name for disk object 1235 | ; IN: d0 = APTR lock (can represent a directory or a file) 1236 | ; d1 = BSTR name (an object name relative to the lock, may contain assign or volume in front) 1237 | ; OUT: d0 = APTR name (size=-(d0), must be freed via exec.FreeMem) 1238 | ; d1 = LONG errcode 1239 | 1240 | .buildname movem.l d3-d7,-(a7) 1241 | moveq #0,d6 ;d6 = length path 1242 | moveq #0,d7 ;d7 = length name 1243 | ;get length of lock 1244 | tst.l d0 1245 | beq .buildname_nolock 1246 | move.l d0,a0 1247 | IFD DEBUG 1248 | cmp.l (fl_Task,a0),a5 1249 | bne _debug4 1250 | ENDC 1251 | move.l (fl_Key,a0),a0 1252 | move.l a0,d4 ;d4 = ptr path 1253 | moveq #-1,d6 1254 | .buildname_cl addq.l #1,d6 1255 | tst.b (a0)+ 1256 | bne .buildname_cl 1257 | .buildname_nolock 1258 | ;get length of name 1259 | move.l d1,a0 ;BSTR 1260 | move.b (a0)+,d7 ;length 1261 | beq .buildname_noname 1262 | ;remove trailing "/" 1263 | cmp.b #1,d7 1264 | beq .buildname_nots 1265 | cmp.b #"/",(-1,a0,d7.l) 1266 | bne .buildname_nots 1267 | subq.l #1,d7 1268 | .buildname_nots 1269 | ;remove leading "xxx:" 1270 | lea (a0,d7.l),a1 ;end 1271 | .buildname_col cmp.b #":",-(a1) 1272 | beq .buildname_fc 1273 | cmp.l a0,a1 1274 | bne .buildname_col 1275 | subq.l #1,a1 1276 | .buildname_fc addq.l #1,a1 1277 | sub.l a1,d7 1278 | add.l a0,d7 1279 | move.l a1,d5 ;d5 = ptr name 1280 | .buildname_noname 1281 | ;allocate memory for object name 1282 | moveq #1+1+4,d0 ;the possible seperator "/", 0 terminator, length 1283 | add.l d6,d0 1284 | add.l d7,d0 1285 | move.l d0,d3 ;d3 = memlen 1286 | move.l #MEMF_ANY,d1 1287 | jsr (_LVOAllocMem,a6) 1288 | tst.l d0 1289 | beq .buildname_mem 1290 | move.l d0,a0 1291 | move.l d3,(a0)+ 1292 | move.l a0,d0 ;d0 = new object memory 1293 | ;copy name 1294 | moveq #"/",d3 ;d3 = "/" 1295 | move.l d4,a1 1296 | move.l d6,d1 1297 | beq .buildname_name 1298 | .buildname_cp move.b (a1)+,(a0)+ 1299 | subq.l #1,d1 1300 | bne .buildname_cp 1301 | ;add seperator 1302 | tst.l d7 1303 | beq .buildname_ok 1304 | move.b d3,(a0)+ 1305 | ;copy path 1306 | .buildname_name move.l d5,a1 1307 | move.l d7,d1 1308 | beq .buildname_ok 1309 | .buildname_cn move.b (a1)+,(a0)+ 1310 | subq.l #1,d1 1311 | bne .buildname_cn 1312 | .buildname_ok clr.b (a0) ;terminate 1313 | ;check for "//" (double slash) and trailing slash's 1314 | move.l d0,a0 1315 | move.l d0,a1 1316 | cmp.b (a0),d3 1317 | beq .buildname_inv ;must not start with a "/" 1318 | .buildname_ds1 move.b (a0)+,d1 1319 | beq .buildname_ds3 1320 | cmp.b d3,d1 1321 | bne .buildname_ds2 1322 | bset #0,d7 ;indicate slash 1323 | beq .buildname_ds3 1324 | ;two slash 1325 | subq.l #1,a1 ;skip already written slash 1326 | cmp.l a1,d0 1327 | bhs .buildname_inv ;already at beginning? 1328 | .buildname_ss cmp.b -(a1),d3 1329 | beq .buildname_ds3 1330 | cmp.l a1,d0 1331 | bne .buildname_ss 1332 | bra .buildname_ds1 1333 | ;copy 1334 | .buildname_ds2 sf d7 ;no slash 1335 | .buildname_ds3 move.b d1,(a1)+ 1336 | bne .buildname_ds1 1337 | tst.b d7 1338 | beq .buildname_sok 1339 | ;trailing slash 1340 | subq.l #2,a1 ;skip already written slash and 0 1341 | cmp.l a1,d0 1342 | bhs .buildname_inv ;already at beginning? 1343 | .buildname_ts1 cmp.b -(a1),d3 1344 | beq .buildname_ts2 1345 | cmp.l a1,d0 1346 | bne .buildname_ts1 1347 | .buildname_ts2 clr.b (a1) 1348 | .buildname_sok 1349 | ;finish 1350 | moveq #0,d1 ;errorcode 1351 | .buildname_quit movem.l (a7)+,d3-d7 1352 | rts 1353 | 1354 | .buildname_inv move.l #ERROR_OBJECT_NOT_FOUND,d1 1355 | bra .buildname_err 1356 | .buildname_mem move.l #ERROR_NO_FREE_STORE,d1 1357 | .buildname_err moveq #DOSFALSE,d0 1358 | bra .buildname_quit 1359 | 1360 | ;--------------- 1361 | ; check for special internal files 1362 | ; IN: a0 = CSTR name 1363 | ; OUT: d0 = APTR filedata 1364 | ; d1 = LONG filelength 1365 | 1366 | IFD BOOTDOS 1367 | .specialfile 1368 | lea (bootfile_ss,pc),a1 1369 | move.l a1,d0 1370 | move.l #bootfile_ss_e-bootfile_ss,d1 1371 | lea (bootname_ss,pc),a1 1372 | bsr .specfile_chk 1373 | beq .specfile_rts 1374 | 1375 | lea (bootfile_exe,pc),a1 1376 | move.l a1,d0 1377 | move.l #bootfile_exe_e-bootfile_exe,d1 1378 | lea (bootname_exe,pc),a1 1379 | bsr .specfile_chk 1380 | beq .specfile_rts 1381 | 1382 | moveq #0,d0 1383 | rts 1384 | 1385 | .specfile_chk move.l a0,-(a7) 1386 | 1387 | .specfile_cmp cmpm.b (a0)+,(a1)+ 1388 | bne .specfile_end 1389 | tst.b (-1,a0) 1390 | bne .specfile_cmp 1391 | 1392 | .specfile_end move.l (a7)+,a0 1393 | .specfile_rts rts 1394 | ENDC 1395 | 1396 | ;--------------- 1397 | 1398 | CNOP 0,4 1399 | .volumename dc.b 7,"WHDLoad",0 ;BSTR (here with the exception that it must be 1400 | ;0-terminated!) 1401 | .devicename dc.b "whdload.device",0 1402 | .handlername dc.b "DH0",0 1403 | .expansionname dc.b "expansion.library",0 1404 | IFD TRACEFS 1405 | .tracefs_name dc.b ".tracefs",0 1406 | ENDC 1407 | IFD SNOOPFS 1408 | .snoopfshead dc.b "[KICKFS] ",0 1409 | .f_current_volume dc.b "%sCURRENT_VOLUME ErrorReport() dl=$%B r2=%ld fha1=$%lx",0 1410 | .f_locate_object dc.b "%sLOCATE_OBJECT Lock() fl=$%B r2=%ld fl=$%B name=%b mode=%ld",0 1411 | .f_free_lock dc.b "%sFREE_LOCK UnLock() succ=%ld r2=%ld fl=$%B",0 1412 | .f_delete_object dc.b "%sDELETE_OBJECT DeleteFile() succ=%ld r2=%ld fl=$%B name=%b",0 1413 | .f_copy_dir dc.b "%sCOPY_DIR DupLock() fl=$%B r2=%ld fl=$%B",0 1414 | .f_set_protect dc.b "%sSET_PROTECT SetProtection() succ=%ld r2=%ld nul=%ld fl=$%B name=%b mask=$%lx",0 1415 | .f_create_dir dc.b "%sCREATE_DIR CreateDir() fl=$%B r2=%ld fl=$%B name=%b",0 1416 | .f_examine_object dc.b "%sEXAMINE_OBJECT Examine() succ=%ld r2=%ld fl=$%B fib=$%B",0 1417 | .f_examine_next dc.b "%sEXAMINE_NEXT ExNext() succ=%ld r2=%ld fl=$%B fib=$%B",0 1418 | .f_disk_info dc.b "%sDISK_INFO cmd.info succ=%ld r2=%ld id=$%B",0 1419 | .f_info dc.b "%sINFO Info() succ=%ld r2=%ld fl=$%B id=$%B",0 1420 | .f_flush dc.b "%sFLUSH cmd.sync succ=%ld",0 1421 | .f_set_comment dc.b "%sSET_COMMENT SetComment() succ=%ld r2=%ld nul=%ld fl=$%B name=%b comm=%b",0 1422 | .f_parent dc.b "%sPARENT ParentDir() fl=$%B r2=%ld fl=$%B",0 1423 | .f_inhibit dc.b "%sINHIBIT Inhibit() succ=%ld r2=%ld bool=%ld",0 1424 | .f_set_date dc.b "%sSET_DATE SetFileDate() succ=%ld r2=%ld nul=%ld fl=$%B name=%b ds=$%lx",0 1425 | .f_read dc.b "%sREAD Read() len=$%lx r2=%ld fha1=$%lx buf=$%lx len=$%lx",0 1426 | .f_write dc.b "%sWRITE Write() len=$%lx r2=%ld fha1=$%lx buf=$%lx len=$%lx",0 1427 | .f_findupdate dc.b "%sFINDUPDATE Open(UPDATE) succ=%ld r2=%ld fh=$%B fl=$%B name=%b",0 1428 | .f_findinput dc.b "%sFINDINPUT Open(OLDFILE) succ=%ld r2=%ld fh=$%B fl=$%B name=%b",0 1429 | .f_findoutput dc.b "%sFINDOUTPUT Open(NEWFILE) succ=%ld r2=%ld fh=$%B fl=$%B name=%b",0 1430 | .f_find dc.b "%sFIND* internal lock Open(*) fl=$%lx <- fh=$%B fl=$%B name=%b",0 1431 | .f_end dc.b "%sEND Close() succ=%ld r2=%ld fha1=$%lx",0 1432 | .f_seek dc.b "%sSEEK Seek() pos=$%lx r2=%ld fha1=$%lx pos=$%lx mode=%ld",0 1433 | IFGT KICKVERSION-36 1434 | .f_same_lock dc.b "%sSAME_LOCK SameLock() succ=%ld r2=%ld fl=$%B fl=$%B",0 1435 | .f_fh_from_lock dc.b "%sFH_FROM_LOCK OpenFromLock() succ=%ld r2=%ld fh=$%B fl=$%B",0 1436 | .f_is_filesystem dc.b "%sIS_FILESYSTEM IsFileSystem() succ=%ld r2=%ld",0 1437 | .f_examine_all dc.b "%sEXAMINE_ALL ExAll() succ=%ld r2=%ld fl=$%B ead=$%lx len=$%lx typ=%ld eac=$%lx",0 1438 | .f_examine_fh dc.b "%sEXAMINE_FH ExamineFH() succ=%ld r2=%ld fha1=$%lx fib=$%B",0 1439 | .f_add_notify dc.b "%sADD_NOTIFY StartNotify() succ=%ld r2=%ld nr=$%lx",0 1440 | ENDC 1441 | ENDC 1442 | _dosname dc.b "dos.library",0 1443 | 1444 | ;--------------- 1445 | 1446 | IFD BOOTDOS 1447 | IFND BOOTFILENAME 1448 | BOOTFILENAME MACRO 1449 | dc.b "WHDBoot.exe" 1450 | ENDM 1451 | ENDC 1452 | CNOP 0,4 1453 | bootfile_exe dc.l $3f3,0,1,0,0,2,$3e9,2 ;exe header 1454 | bootfile_exe_j jmp $99999999 ;avoid optimizing! 1455 | dc.w 0 ;pad to longword 1456 | dc.l $3f2 ;exe footer 1457 | bootfile_exe_e 1458 | bootname_ss_b dc.b 10 ;BSTR 1459 | bootname_ss dc.b "WHDBoot.ss",0 ;name of ':s/startup-sequence' 1460 | bootfile_ss BOOTFILENAME 1461 | dc.b 10 1462 | bootfile_ss_e 1463 | bootname_exe BOOTFILENAME 1464 | dc.b 0 1465 | ELSE 1466 | ss_name dc.b "s/startup-sequence",0 1467 | ENDC 1468 | 1469 | ;--------------- 1470 | 1471 | EVEN 1472 | -------------------------------------------------------------------------------- /Amiga/WHDLoad/PETSCIIRobotsInstall/Source/makefile: -------------------------------------------------------------------------------- 1 | PROGNAME = PETSCIIRobots 2 | WHDLOADER = $(PROGNAME).slave 3 | SOURCE = $(PROGNAME).s 4 | 5 | all : $(WHDLOADER) 6 | 7 | $(WHDLOADER) : $(SOURCE) 8 | basm $(SOURCE) 9 | 10 | clean: 11 | delete $(WHDLOADER) 12 | -------------------------------------------------------------------------------- /Amiga/amigaicon.iff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeropolis79/PETSCIIRobots-Amiga/266132967fd50eb44080d90c8221c2449daaf540/Amiga/amigaicon.iff -------------------------------------------------------------------------------- /Amiga/animtiles.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeropolis79/PETSCIIRobots-Amiga/266132967fd50eb44080d90c8221c2449daaf540/Amiga/animtiles.png -------------------------------------------------------------------------------- /Amiga/c/Avail: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeropolis79/PETSCIIRobots-Amiga/266132967fd50eb44080d90c8221c2449daaf540/Amiga/c/Avail -------------------------------------------------------------------------------- /Amiga/c/Check512k: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeropolis79/PETSCIIRobots-Amiga/266132967fd50eb44080d90c8221c2449daaf540/Amiga/c/Check512k -------------------------------------------------------------------------------- /Amiga/c/Echo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeropolis79/PETSCIIRobots-Amiga/266132967fd50eb44080d90c8221c2449daaf540/Amiga/c/Echo -------------------------------------------------------------------------------- /Amiga/c/Endif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeropolis79/PETSCIIRobots-Amiga/266132967fd50eb44080d90c8221c2449daaf540/Amiga/c/Endif -------------------------------------------------------------------------------- /Amiga/c/If: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeropolis79/PETSCIIRobots-Amiga/266132967fd50eb44080d90c8221c2449daaf540/Amiga/c/If -------------------------------------------------------------------------------- /Amiga/c64font.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeropolis79/PETSCIIRobots-Amiga/266132967fd50eb44080d90c8221c2449daaf540/Amiga/c64font.png -------------------------------------------------------------------------------- /Amiga/devs/system-configuration: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeropolis79/PETSCIIRobots-Amiga/266132967fd50eb44080d90c8221c2449daaf540/Amiga/devs/system-configuration -------------------------------------------------------------------------------- /Amiga/faces.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeropolis79/PETSCIIRobots-Amiga/266132967fd50eb44080d90c8221c2449daaf540/Amiga/faces.png -------------------------------------------------------------------------------- /Amiga/gameover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeropolis79/PETSCIIRobots-Amiga/266132967fd50eb44080d90c8221c2449daaf540/Amiga/gameover.png -------------------------------------------------------------------------------- /Amiga/gamescreen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeropolis79/PETSCIIRobots-Amiga/266132967fd50eb44080d90c8221c2449daaf540/Amiga/gamescreen.png -------------------------------------------------------------------------------- /Amiga/health.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeropolis79/PETSCIIRobots-Amiga/266132967fd50eb44080d90c8221c2449daaf540/Amiga/health.png -------------------------------------------------------------------------------- /Amiga/introscreen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeropolis79/PETSCIIRobots-Amiga/266132967fd50eb44080d90c8221c2449daaf540/Amiga/introscreen.png -------------------------------------------------------------------------------- /Amiga/items.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeropolis79/PETSCIIRobots-Amiga/266132967fd50eb44080d90c8221c2449daaf540/Amiga/items.png -------------------------------------------------------------------------------- /Amiga/keys.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeropolis79/PETSCIIRobots-Amiga/266132967fd50eb44080d90c8221c2449daaf540/Amiga/keys.png -------------------------------------------------------------------------------- /Amiga/move.iff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeropolis79/PETSCIIRobots-Amiga/266132967fd50eb44080d90c8221c2449daaf540/Amiga/move.iff -------------------------------------------------------------------------------- /Amiga/petfont.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeropolis79/PETSCIIRobots-Amiga/266132967fd50eb44080d90c8221c2449daaf540/Amiga/petfont.png -------------------------------------------------------------------------------- /Amiga/peticon.iff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeropolis79/PETSCIIRobots-Amiga/266132967fd50eb44080d90c8221c2449daaf540/Amiga/peticon.iff -------------------------------------------------------------------------------- /Amiga/s/startup-sequence: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeropolis79/PETSCIIRobots-Amiga/266132967fd50eb44080d90c8221c2449daaf540/Amiga/s/startup-sequence -------------------------------------------------------------------------------- /Amiga/search.iff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeropolis79/PETSCIIRobots-Amiga/266132967fd50eb44080d90c8221c2449daaf540/Amiga/search.iff -------------------------------------------------------------------------------- /Amiga/sprites.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeropolis79/PETSCIIRobots-Amiga/266132967fd50eb44080d90c8221c2449daaf540/Amiga/sprites.png -------------------------------------------------------------------------------- /Amiga/spritesalpha.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeropolis79/PETSCIIRobots-Amiga/266132967fd50eb44080d90c8221c2449daaf540/Amiga/spritesalpha.png -------------------------------------------------------------------------------- /Amiga/spritesmask.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeropolis79/PETSCIIRobots-Amiga/266132967fd50eb44080d90c8221c2449daaf540/Amiga/spritesmask.png -------------------------------------------------------------------------------- /Amiga/tiles.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeropolis79/PETSCIIRobots-Amiga/266132967fd50eb44080d90c8221c2449daaf540/Amiga/tiles.png -------------------------------------------------------------------------------- /Amiga/tilesalpha.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeropolis79/PETSCIIRobots-Amiga/266132967fd50eb44080d90c8221c2449daaf540/Amiga/tilesalpha.png -------------------------------------------------------------------------------- /Arcade/.gitignore: -------------------------------------------------------------------------------- 1 | mod.* 2 | level-* 3 | *.raw.gz 4 | -------------------------------------------------------------------------------- /Arcade/Attract1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeropolis79/PETSCIIRobots-Amiga/266132967fd50eb44080d90c8221c2449daaf540/Arcade/Attract1.png -------------------------------------------------------------------------------- /Arcade/Attract1.raw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeropolis79/PETSCIIRobots-Amiga/266132967fd50eb44080d90c8221c2449daaf540/Arcade/Attract1.raw -------------------------------------------------------------------------------- /Arcade/Attract2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeropolis79/PETSCIIRobots-Amiga/266132967fd50eb44080d90c8221c2449daaf540/Arcade/Attract2.png -------------------------------------------------------------------------------- /Arcade/Attract2.raw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeropolis79/PETSCIIRobots-Amiga/266132967fd50eb44080d90c8221c2449daaf540/Arcade/Attract2.raw -------------------------------------------------------------------------------- /Arcade/Attract3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeropolis79/PETSCIIRobots-Amiga/266132967fd50eb44080d90c8221c2449daaf540/Arcade/Attract3.png -------------------------------------------------------------------------------- /Arcade/Attract3.raw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeropolis79/PETSCIIRobots-Amiga/266132967fd50eb44080d90c8221c2449daaf540/Arcade/Attract3.raw -------------------------------------------------------------------------------- /Arcade/Data/IntroScreen.raw.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeropolis79/PETSCIIRobots-Amiga/266132967fd50eb44080d90c8221c2449daaf540/Arcade/Data/IntroScreen.raw.gz -------------------------------------------------------------------------------- /Arcade/introscreen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeropolis79/PETSCIIRobots-Amiga/266132967fd50eb44080d90c8221c2449daaf540/Arcade/introscreen.png -------------------------------------------------------------------------------- /Arcade/setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ ! -f setup.sh ] 4 | then 5 | cd Arcade 6 | fi 7 | 8 | if [ ! -f Data/GameScreen.raw.gz ] 9 | then 10 | mkdir -p Data 11 | cd Data 12 | for file in ../../Amiga/Data/level-*.gz ../../Amiga/Data/mod.*.gz ../../Amiga/Data/Game*.gz 13 | do 14 | ln -s "$file" 15 | done 16 | fi 17 | -------------------------------------------------------------------------------- /DecompressData.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | __asm int ungzip__FPvPv(register __a0 void* input, register __a1 void* output); 6 | 7 | unsigned char* input = 0; 8 | unsigned char* output = 0; 9 | unsigned long inputSize = 0; 10 | unsigned long outputSize = 0; 11 | 12 | int cleanup(int returnCode, char* error) 13 | { 14 | if (output) { 15 | FreeMem(output, outputSize); 16 | } 17 | 18 | if (input) { 19 | FreeMem(input, inputSize); 20 | } 21 | 22 | if (error) { 23 | char *errorEnd = error; 24 | while (*errorEnd) { 25 | errorEnd++; 26 | } 27 | 28 | Write(Output(), error, errorEnd - error); 29 | } 30 | 31 | return returnCode; 32 | } 33 | 34 | int main(int argc, char *argv[]) 35 | { 36 | BPTR lock, file; 37 | struct FileInfoBlock fib; 38 | 39 | if (argc != 3) { 40 | return cleanup(10, "Usage: DecompressData input output\n"); 41 | } 42 | 43 | lock = Lock(argv[1], ACCESS_READ); 44 | if (lock) { 45 | if (Examine(lock, &fib)) { 46 | UnLock(lock); 47 | 48 | inputSize = fib.fib_Size; 49 | input = AllocMem(inputSize, MEMF_ANY); 50 | if (!input) { 51 | return cleanup(10, "Unable to allocate memory\n"); 52 | } 53 | 54 | file = Open(argv[1], MODE_OLDFILE); 55 | if (file) { 56 | Read(file, input, inputSize); 57 | outputSize = (input[inputSize - 1] << 24) | (input[inputSize - 2] << 16) | (input[inputSize - 3] << 8) | input[inputSize - 4]; 58 | Close(file); 59 | 60 | output = AllocMem(outputSize, MEMF_ANY); 61 | if (!output) { 62 | return cleanup(10, "Unable to allocate memory\n"); 63 | } 64 | 65 | ungzip__FPvPv(input, output); 66 | 67 | file = Open(argv[2], MODE_NEWFILE); 68 | if (file) { 69 | Write(file, output, outputSize); 70 | Close(file); 71 | 72 | return cleanup(0, 0); 73 | } else { 74 | return cleanup(10, "Unable to open output file\n"); 75 | } 76 | } 77 | } 78 | } 79 | 80 | return cleanup(10, "Unable to open input file\n"); 81 | } 82 | -------------------------------------------------------------------------------- /LICENCE1: -------------------------------------------------------------------------------- 1 | The source-code is being provided as is. You can study it and modify it but you can't distribute any direct modifications without permission from David Murray. If you think a modification is good, you can contact us 2 | and it MIGHT be able to form part of official builds. 3 | Commerical exploitation is not permitted, again without permission from David Murray. 4 | The source-code CAN be used to adapt the game to run on other systems but any new ports must NOT be distributed without David's permission and it would be appreciated that any new ports would have their source-code be 5 | made avaliable for Github. 6 | Enhanced versions which run on a particular set of source code (like gZDoom) can be freely distributed but the end user must provide the source files from a legally purchased copy of the game themselves - no source files 7 | are to be distributed. Myself and David Murray will not provide any technical support for enhanced versions. 8 | I myself am not responsible for technical issues, especially when it comes to compiling source code as I have no knowledge of it but I can be approached when it comes to testing. 9 | -------------------------------------------------------------------------------- /Music/mod.get psyched: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeropolis79/PETSCIIRobots-Amiga/266132967fd50eb44080d90c8221c2449daaf540/Music/mod.get psyched -------------------------------------------------------------------------------- /Music/mod.lose: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeropolis79/PETSCIIRobots-Amiga/266132967fd50eb44080d90c8221c2449daaf540/Music/mod.lose -------------------------------------------------------------------------------- /Music/mod.metal heads: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeropolis79/PETSCIIRobots-Amiga/266132967fd50eb44080d90c8221c2449daaf540/Music/mod.metal heads -------------------------------------------------------------------------------- /Music/mod.metallic bop amiga: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeropolis79/PETSCIIRobots-Amiga/266132967fd50eb44080d90c8221c2449daaf540/Music/mod.metallic bop amiga -------------------------------------------------------------------------------- /Music/mod.robot attack: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeropolis79/PETSCIIRobots-Amiga/266132967fd50eb44080d90c8221c2449daaf540/Music/mod.robot attack -------------------------------------------------------------------------------- /Music/mod.rushin in: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeropolis79/PETSCIIRobots-Amiga/266132967fd50eb44080d90c8221c2449daaf540/Music/mod.rushin in -------------------------------------------------------------------------------- /Music/mod.soundfx: -------------------------------------------------------------------------------- 1 | soundfx@@@@@@@@@@@@@@@@M.K. -------------------------------------------------------------------------------- /Music/mod.win: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeropolis79/PETSCIIRobots-Amiga/266132967fd50eb44080d90c8221c2449daaf540/Music/mod.win -------------------------------------------------------------------------------- /PT2.3F_replay_cia.h: -------------------------------------------------------------------------------- 1 | #ifndef _PT23F_REPLAY_CIA_H 2 | #define _PT23F_REPLAY_CIA_H 3 | 4 | #include "Platform.h" 5 | 6 | struct SampleData { 7 | char name[22]; 8 | uint16_t length; 9 | int8_t finetune; 10 | uint8_t volume; 11 | uint16_t repeatPoint; 12 | uint16_t repeatLength; 13 | }; 14 | 15 | struct ChanTemp { 16 | uint16_t note; 17 | uint16_t cmd; 18 | int8_t* start; 19 | uint16_t length; 20 | int8_t* loopstart; 21 | uint16_t replen; 22 | uint16_t period; 23 | uint8_t finetune; 24 | uint8_t volume; 25 | uint16_t dmabit; 26 | uint8_t toneportdirec; 27 | uint8_t toneportspeed; 28 | uint16_t wantedperiod; 29 | uint8_t vibratocmd; 30 | uint8_t vibratopos; 31 | uint8_t tremolocmd; 32 | uint8_t tremolopos; 33 | uint8_t wavecontrol; 34 | uint8_t glissfunk; 35 | uint8_t sampleoffset; 36 | uint8_t pattpos; 37 | uint8_t loopcount; 38 | uint8_t funkoffset; 39 | uint32_t wavestart; 40 | uint16_t padding; 41 | }; 42 | 43 | struct ChanInput { 44 | uint16_t note; 45 | uint16_t cmd; 46 | }; 47 | 48 | __asm extern void SetCIAInt(void); 49 | __asm extern void ResetCIAInt(void); 50 | __asm extern void mt_init(register __a0 uint8_t* songData); 51 | __asm extern void mt_music(void); 52 | __asm extern void mt_end(void); 53 | __far extern ChanTemp mt_chan1temp; 54 | __far extern ChanTemp mt_chan2temp; 55 | __far extern ChanTemp mt_chan3temp; 56 | __far extern ChanTemp mt_chan4temp; 57 | __far extern int8_t* mt_SampleStarts[31]; 58 | __far extern uint8_t* mt_data; 59 | __far extern uint8_t mt_speed; 60 | __far extern uint8_t mt_SongPos; 61 | __far extern bool mt_Enable; 62 | __far extern uint16_t mt_PatternPos; 63 | __far extern ChanInput mt_chan1input; 64 | __far extern ChanInput mt_chan2input; 65 | __far extern ChanInput mt_chan3input; 66 | __far extern ChanInput mt_chan4input; 67 | 68 | #endif 69 | -------------------------------------------------------------------------------- /PT2.3F_replay_cia.s: -------------------------------------------------------------------------------- 1 | xdef _SetCIAInt__Fv 2 | xdef _ResetCIAInt__Fv 3 | xdef _mt_init__FPUc 4 | xdef _mt_music__Fv 5 | xdef _mt_end__Fv 6 | xdef _mt_chan1temp 7 | xdef _mt_chan2temp 8 | xdef _mt_chan3temp 9 | xdef _mt_chan4temp 10 | xdef _mt_SampleStarts 11 | xdef _mt_data 12 | xdef _mt_speed 13 | xdef _mt_SongPos 14 | xdef _mt_Enable 15 | xdef _mt_PatternPos 16 | xdef _mt_chan1input 17 | xdef _mt_chan2input 18 | xdef _mt_chan3input 19 | xdef _mt_chan4input 20 | 21 | section code 22 | 23 | ;************************************************* 24 | ;* ----- ProTracker V2.3F Replay Routine ----- * 25 | ;************************************************* 26 | 27 | ; CIA Version: 28 | ; Call SetCIAInt to install the interrupt server. Then call mt_init 29 | ; to initialize the song. Playback starts when the mt_enable flag 30 | ; is set to a non-zero value. To end the song and turn off all voices, 31 | ; call mt_end. At last, call ResetCIAInt to remove the interrupt. 32 | ; 33 | ; This replay routine is modified to work exactly like the tracker replayer, 34 | ; thus it is super accurate but not not optimized in any way. The only 35 | ; difference is that it fully supports loop points above 65535. 36 | ; 37 | ; You can use this routine to play a module. Just remove the semicolons. 38 | ; Also change the module path in mt_data at the very bottom of this file. 39 | ; Exit by pressing both mouse buttons. 40 | ; 41 | ;main BSR.S SetCIAInt 42 | ; BSR mt_init 43 | ; ST mt_Enable 44 | ; MOVE.L 4.W,A6 45 | ; LEA DOSname(PC),A1 46 | ; MOVEQ #0,D0 47 | ; JSR LVOOpenLibrary(A6) 48 | ; TST.L D0 49 | ; BEQ.S theend 50 | ; MOVE.L D0,A6 51 | ;wloop MOVEQ #10,D1 52 | ; JSR LVODelay(A6) 53 | ; BTST #6,$BFE001 54 | ; BNE.S wloop 55 | ; BTST #2,$DFF016 56 | ; BNE.S wloop 57 | ; MOVE.L A6,A1 58 | ; MOVE.L 4.W,A6 59 | ; JSR LVOCloseLibrary(A6) 60 | ;theend BSR mt_end 61 | ; BSR ResetCIAInt 62 | ; RTS 63 | 64 | ;DOSname dc.b "dos.library",0 65 | 66 | ;---- CIA Interrupt ---- 67 | 68 | AddICRVector equ -6 69 | RemICRVector equ -12 70 | LVOOpenResource equ -498 71 | LVOOpenLibrary equ -552 72 | LVOCloseLibrary equ -414 73 | LVODelay equ -198 74 | 75 | ciatalo equ $400 76 | ciatahi equ $500 77 | ciatblo equ $600 78 | ciatbhi equ $700 79 | ciacra equ $E00 80 | ciacrb equ $F00 81 | 82 | _SetCIAInt__Fv 83 | movem.l d0-d7/a0-a5,-(sp) 84 | 85 | MOVEQ #2,D6 86 | LEA $BFD000,A5 87 | MOVE.B #'b',CIAAname+3 88 | SetCIALoop 89 | MOVEQ #0,D0 90 | LEA CIAAname(PC),A1 91 | MOVE.L 4.W,A6 92 | JSR LVOOpenResource(A6) 93 | MOVE.L D0,CIAAbase 94 | BEQ mt_ReturnToC 95 | 96 | LEA GfxName(PC),A1 97 | MOVEQ #0,D0 98 | JSR LVOOpenLibrary(A6) 99 | TST.L D0 100 | BEQ _ResetCIAInt__Fv 101 | MOVE.L D0,A1 102 | MOVE.W 206(A1),D0 ; DisplayFlags 103 | BTST #2,D0 ; PAL? 104 | BEQ.S WasNTSC 105 | MOVE.L #1773447,D7 ; PAL 106 | BRA.S sciask 107 | WasNTSC MOVE.L #1789773,D7 ; NTSC 108 | sciask MOVE.L D7,TimerValue 109 | DIVU #125,D7 ; Default to normal 50 Hz timer 110 | JSR LVOCloseLibrary(A6) 111 | 112 | MOVE.L CIAAbase(PC),A6 113 | CMP.W #2,D6 114 | BEQ.S TryTimerA 115 | TryTimerB 116 | LEA MusicIntServer(PC),A1 117 | MOVEQ #1,D0 ; Bit 1: Timer B 118 | JSR AddICRVector(A6) 119 | MOVE.L #1,TimerFlag 120 | TST.L D0 121 | BNE.S CIAError 122 | MOVE.L A5,CIAAaddr 123 | MOVE.B D7,ciatblo(A5) 124 | LSR.W #8,D7 125 | MOVE.B D7,ciatbhi(A5) 126 | BSET #0,ciacrb(A5) 127 | 128 | movem.l (sp)+,d0-d7/a0-a5 129 | RTS 130 | 131 | TryTimerA 132 | LEA MusicIntServer(PC),A1 133 | MOVEQ #0,D0 ; Bit 0: Timer A 134 | JSR AddICRVector(A6) 135 | CLR.L TimerFlag 136 | TST.L D0 137 | BNE.S CIAError 138 | MOVE.L A5,CIAAaddr 139 | MOVE.B D7,ciatalo(A5) 140 | LSR.W #8,D7 141 | MOVE.B D7,ciatahi(A5) 142 | BSET #0,ciacra(A5) 143 | 144 | movem.l (sp)+,d0-d7/a0-a5 145 | RTS 146 | 147 | CIAError 148 | MOVE.B #'a',CIAAname+3 149 | LEA $BFE001,A5 150 | SUBQ.W #1,D6 151 | BNE SetCIALoop 152 | CLR.L CIAAbase 153 | 154 | movem.l (sp)+,d0-d7/a0-a5 155 | RTS 156 | 157 | _ResetCIAInt__Fv 158 | tst.l CIAAaddr 159 | bne.s ResCIAInt 160 | rts 161 | 162 | ResCIAInt 163 | movem.l d0-d7/a0-a5,-(sp) 164 | 165 | MOVE.L CIAAbase(PC),D0 166 | BEQ mt_ReturnToC 167 | CLR.L CIAAbase 168 | MOVE.L D0,A6 169 | MOVE.L CIAAaddr(PC),A5 170 | TST.L TimerFlag 171 | BEQ.S ResTimerA 172 | 173 | BCLR #0,ciacrb(A5) 174 | MOVEQ #1,D0 175 | BRA.S RemInt 176 | 177 | ResTimerA 178 | BCLR #0,ciacra(A5) 179 | MOVEQ #0,D0 180 | RemInt LEA MusicIntServer(PC),A1 181 | MOVEQ #0,d0 182 | JSR RemICRVector(A6) 183 | 184 | mt_ReturnToC 185 | movem.l (sp)+,d0-d7/a0-a5 186 | RTS 187 | 188 | 189 | ;---- Tempo ---- 190 | 191 | SetTempo 192 | MOVE.L CIAAbase(PC),D2 193 | BEQ mt_Return 194 | CMP.W #32,D0 195 | BHS.S setemsk 196 | MOVEQ #32,D0 197 | setemsk MOVE.W D0,RealTempo 198 | MOVE.L TimerValue(PC),D2 199 | DIVU D0,D2 200 | MOVE.L CIAAaddr(PC),A4 201 | MOVE.L TimerFlag(PC),D0 202 | BEQ.S SetTemA 203 | MOVE.B D2,ciatblo(A4) 204 | LSR.W #8,D2 205 | MOVE.B D2,ciatbhi(A4) 206 | RTS 207 | 208 | SetTemA MOVE.B D2,ciatalo(A4) 209 | LSR.W #8,D2 210 | MOVE.B D2,ciatahi(A4) 211 | RTS 212 | 213 | RealTempo dc.w 125 214 | CIAAaddr dc.l 0 215 | CIAAname dc.b "ciaa.resource",0 216 | CIAAbase dc.l 0 217 | TimerFlag dc.l 0 218 | TimerValue dc.l 0 219 | GfxName dc.b "graphics.library",0,0 220 | 221 | MusicIntServer 222 | dc.l 0,0 223 | dc.b 2,5 ; type, priority 224 | dc.l musintname 225 | dc.l 0,mt_music 226 | 227 | musintname dc.b "Attack of the PETSCII Robots CIA",0,0 228 | 229 | ;---- Playroutine ---- 230 | 231 | n_note EQU 0 ; W 232 | n_cmd EQU 2 ; W 233 | n_cmdlo EQU 3 ; B 234 | n_start EQU 4 ; L 235 | n_length EQU 8 ; W 236 | n_loopstart EQU 10 ; L 237 | n_replen EQU 14 ; W 238 | n_period EQU 16 ; W 239 | n_finetune EQU 18 ; B 240 | n_volume EQU 19 ; B 241 | n_dmabit EQU 20 ; W 242 | n_toneportdirec EQU 22 ; B 243 | n_toneportspeed EQU 23 ; B 244 | n_wantedperiod EQU 24 ; W 245 | n_vibratocmd EQU 26 ; B 246 | n_vibratopos EQU 27 ; B 247 | n_tremolocmd EQU 28 ; B 248 | n_tremolopos EQU 29 ; B 249 | n_wavecontrol EQU 30 ; B 250 | n_glissfunk EQU 31 ; B 251 | n_sampleoffset EQU 32 ; B 252 | n_pattpos EQU 33 ; B 253 | n_loopcount EQU 34 ; B 254 | n_funkoffset EQU 35 ; B 255 | n_wavestart EQU 36 ; L 256 | 257 | _mt_init__FPUc 258 | movem.l d2-d3/a2/a4,-(sp) 259 | 260 | MOVE.L A0,mt_SongDataPtr 261 | 262 | ; count number of patterns (find highest referred pattern) 263 | MOVE.L A0,A1 264 | LEA 952(A1),A1 ; order list address 265 | MOVEQ #128-1,D0 ; 128 order list entries 266 | MOVEQ #0,D1 267 | mtloop MOVE.L D1,D2 268 | SUBQ.W #1,D0 269 | mtloop2 MOVE.B (A1)+,D1 270 | CMP.B D2,D1 271 | BGT.S mtloop 272 | DBRA D0,mtloop2 273 | ADDQ.B #1,D2 274 | 275 | ; generate mt_SampleStarts list and fix samples 276 | LEA mt_SampleStarts,A1 277 | ASL.L #8,D2 278 | ASL.L #2,D2 279 | ADD.L #1084,D2 280 | ADD.L A0,D2 281 | MOVE.L D2,A2 ; A2 is now the address of first sample's data 282 | MOVEQ #15-1,D0 ; handle 15 samples 283 | mtloop3 284 | MOVE.W 28(A0),D3 ; get replen 285 | TST.W D3 ; replen is zero? 286 | BNE.S mtskip ; no 287 | MOVE.W #1,28(A0) ; yes, set to 1 (fixes lock-up) 288 | mtskip 289 | CMP.W #1,D3 ; loop enabled? 290 | BHI.S mtskip2 ; yes 291 | CLR.W (A2) ; no, clear first two bytes of sample 292 | mtskip2 293 | MOVE.L A2,(A1)+ ; move sample address into mt_SampleStarts slot 294 | MOVEQ #0,D1 295 | MOVE.W 42(A0),D1 ; get sample length 296 | ADD.L D1,D1 ; turn into real sample length 297 | ADD.L D1,A2 ; add to address 298 | ADD.L #30,A0 ; skip to next sample list entry 299 | DBRA D0,mtloop3 300 | 301 | ; initialize stuff 302 | ;OR.B #2,$BFE001 303 | move.l #$00010000,mt_chan1temp+20 304 | move.l #$00020000,mt_chan2temp+20 305 | move.l #$00040000,mt_chan3temp+20 306 | move.l #$00080000,mt_chan4temp+20 307 | MOVE.B #6,mt_speed 308 | CLR.B mt_counter 309 | CLR.B mt_SongPos 310 | CLR.W mt_PatternPos 311 | move.w #125,d0 312 | bsr SetTempo 313 | movem.l (sp)+,d2-d3/a2/a4 314 | 315 | _mt_end__Fv 316 | SF mt_Enable 317 | LEA $DFF000,A0 318 | CLR.W $A8(A0) 319 | CLR.W $B8(A0) 320 | CLR.W $C8(A0) 321 | CLR.W $D8(A0) 322 | MOVE.W #$000F,$DFF096 323 | RTS 324 | 325 | _mt_music__Fv 326 | mt_music 327 | MOVEM.L D0-D7/A0-A6,-(SP) 328 | TST.B mt_Enable 329 | BEQ mt_exit 330 | ADDQ.B #1,mt_counter 331 | MOVE.B mt_counter,D0 332 | CMP.B mt_speed,D0 333 | BLO.S mt_NoNewNote 334 | CLR.B mt_counter 335 | TST.B mt_PattDelTime2 336 | BEQ.S mt_GetNewNote 337 | BSR.S mt_NoNewAllChannels 338 | BRA mt_dskip 339 | 340 | mt_NoNewNote 341 | BSR.S mt_NoNewAllChannels 342 | BRA mt_NoNewPosYet 343 | 344 | mt_NoNewAllChannels 345 | LEA $DFF0A0,A5 346 | LEA mt_chan1temp,A6 347 | BSR mt_CheckEffects 348 | LEA $DFF0B0,A5 349 | LEA mt_chan2temp,A6 350 | BSR mt_CheckEffects 351 | LEA $DFF0C0,A5 352 | LEA mt_chan3temp,A6 353 | BSR mt_CheckEffects 354 | LEA $DFF0D0,A5 355 | LEA mt_chan4temp,A6 356 | BRA mt_CheckEffects 357 | 358 | mt_GetNewNote 359 | MOVE.L mt_SongDataPtr,A0 360 | LEA 12(A0),A3 361 | LEA 952(A0),A2 ;pattpo 362 | LEA 1084(A0),A0 ;patterndata 363 | MOVEQ #0,D0 364 | MOVEQ #0,D1 365 | MOVE.B mt_SongPos,D0 366 | MOVE.B (A2,D0.W),D1 367 | ASL.L #8,D1 368 | ASL.L #2,D1 369 | ADD.W mt_PatternPos,D1 370 | CLR.W mt_DMACONtemp 371 | 372 | LEA $DFF0A0,A5 373 | movem.l a0/d1,-(sp) 374 | tst.l mt_chan1input 375 | beq.s mt_PlayChannel1 376 | lea mt_chan1input,a0 377 | moveq #0,d1 378 | mt_PlayChannel1 379 | LEA mt_chan1temp,A6 380 | BSR mt_PlayVoice 381 | MOVEQ #0,D0 382 | MOVE.B n_volume(A6),D0 383 | MOVE.W D0,8(A5) 384 | clr.l mt_chan1input 385 | 386 | LEA $DFF0B0,A5 387 | move.l (sp),a0 388 | move.l 4(sp),d1 389 | addq #4,d1 390 | tst.l mt_chan2input 391 | beq.s mt_PlayChannel2 392 | lea mt_chan2input,a0 393 | moveq #0,d1 394 | mt_PlayChannel2 395 | LEA mt_chan2temp,A6 396 | BSR mt_PlayVoice 397 | MOVEQ #0,D0 398 | MOVE.B n_volume(A6),D0 399 | MOVE.W D0,8(A5) 400 | clr.l mt_chan2input 401 | 402 | LEA $DFF0C0,A5 403 | move.l (sp),a0 404 | move.l 4(sp),d1 405 | addq #8,d1 406 | tst.l mt_chan3input 407 | beq.s mt_PlayChannel3 408 | lea mt_chan3input,a0 409 | moveq #0,d1 410 | mt_PlayChannel3 411 | LEA mt_chan3temp,A6 412 | BSR mt_PlayVoice 413 | MOVEQ #0,D0 414 | MOVE.B n_volume(A6),D0 415 | MOVE.W D0,8(A5) 416 | clr.l mt_chan3input 417 | 418 | LEA $DFF0D0,A5 419 | movem.l (sp)+,a0/d1 420 | add.l #12,d1 421 | tst.l mt_chan4input 422 | beq.s mt_PlayChannel4 423 | lea mt_chan4input,a0 424 | moveq #0,d1 425 | mt_PlayChannel4 426 | LEA mt_chan4temp,A6 427 | BSR mt_PlayVoice 428 | MOVEQ #0,D0 429 | MOVE.B n_volume(A6),D0 430 | MOVE.W D0,8(A5) 431 | clr.l mt_chan4input 432 | BRA mt_SetDMA 433 | 434 | mt_PlayVoice 435 | TST.L (A6) 436 | BNE.S mt_plvskip 437 | BSR mt_PerNop 438 | mt_plvskip 439 | MOVE.L (A0,D1.L),(A6) ; Read note from pattern 440 | ; ADDQ.L #4,D1 441 | MOVEQ #0,D2 442 | MOVE.B n_cmd(A6),D2 ; Get lower 4 bits of instrument 443 | AND.B #$F0,D2 444 | LSR.B #4,D2 445 | MOVE.B (A6),D0 ; Get higher 4 bits of instrument 446 | AND.B #$F0,D0 447 | OR.B D0,D2 448 | TST.B D2 449 | BEQ mt_SetRegs ; Instrument was zero 450 | MOVEQ #0,D3 451 | LEA mt_SampleStarts,A1 452 | MOVE D2,D4 453 | SUBQ.L #1,D2 454 | ASL.L #2,D2 455 | MULU #30,D4 456 | MOVE.L (A1,D2.L),n_start(A6) 457 | MOVE.W (A3,D4.L),n_length(A6) 458 | MOVE.B 2(A3,D4.L),n_finetune(A6) 459 | AND.B #$0F,n_finetune(A6) ; --PT2.3D bug fix: mask finetune... 460 | MOVE.B 3(A3,D4.L),n_volume(A6) 461 | MOVE.W 4(A3,D4.L),D3 ; Get repeat 462 | TST.W D3 463 | BEQ.S mt_NoLoop 464 | MOVE.L n_start(A6),D2 ; Get start 465 | ADD.L D3,D3 ; PT2.3D bug fix: 128kB sample support 466 | ADD.L D3,D2 ; Add repeat 467 | MOVE.L D2,n_loopstart(A6) 468 | MOVE.L D2,n_wavestart(A6) 469 | MOVE.W 4(A3,D4.L),D0 ; Get repeat 470 | ADD.W 6(A3,D4.L),D0 ; Add replen 471 | MOVE.W D0,n_length(A6) 472 | MOVE.W 6(A3,D4.L),n_replen(A6) ; Save replen 473 | BRA.S mt_SetRegs 474 | 475 | mt_NoLoop 476 | MOVE.L n_start(A6),D2 477 | ADD.L D3,D2 478 | MOVE.L D2,n_loopstart(A6) 479 | MOVE.L D2,n_wavestart(A6) 480 | MOVE.W 6(A3,D4.L),n_replen(A6) ; Save replen 481 | mt_SetRegs 482 | MOVE.W (A6),D0 483 | AND.W #$0FFF,D0 484 | BEQ mt_CheckMoreEfx ; If no note 485 | MOVE.W 2(A6),D0 486 | AND.W #$0FF0,D0 487 | CMP.W #$0E50,D0 ; finetune 488 | BEQ.S mt_DoSetFineTune 489 | MOVE.B 2(A6),D0 490 | AND.B #$0F,D0 491 | CMP.B #3,D0 ; TonePortamento 492 | BEQ.S mt_ChkTonePorta 493 | CMP.B #5,D0 ; TonePortamento + VolSlide 494 | BEQ.S mt_ChkTonePorta 495 | CMP.B #9,D0 ; Sample Offset 496 | BNE.S mt_SetPeriod 497 | BSR mt_CheckMoreEfx 498 | BRA.S mt_SetPeriod 499 | 500 | mt_DoSetFineTune 501 | BSR mt_SetFineTune 502 | BRA.S mt_SetPeriod 503 | 504 | mt_ChkTonePorta 505 | BSR mt_SetTonePorta 506 | BRA mt_CheckMoreEfx 507 | 508 | mt_SetPeriod 509 | MOVEM.L D0/D1/A0/A1,-(SP) 510 | MOVE.W (A6),D1 511 | AND.W #$0FFF,D1 512 | LEA mt_PeriodTable(PC),A1 513 | MOVEQ #0,D0 514 | MOVEQ #$24,D7 515 | mt_ftuloop 516 | CMP.W (A1,D0.W),D1 517 | BHS.S mt_ftufound 518 | ADDQ.L #2,D0 519 | DBRA D7,mt_ftuloop 520 | mt_ftufound 521 | MOVEQ #0,D1 522 | MOVE.B n_finetune(A6),D1 523 | MULU #37*2,D1 524 | ADD.L D1,A1 525 | MOVE.W (A1,D0.W),n_period(A6) 526 | MOVEM.L (SP)+,D0/D1/A0/A1 527 | 528 | MOVE.W 2(A6),D0 529 | AND.W #$0FF0,D0 530 | CMP.W #$0ED0,D0 ; Notedelay 531 | BEQ mt_CheckMoreEfx 532 | 533 | MOVE.W n_dmabit(A6),$DFF096 534 | BTST #2,n_wavecontrol(A6) 535 | BNE.S mt_vibnoc 536 | CLR.B n_vibratopos(A6) 537 | mt_vibnoc 538 | BTST #6,n_wavecontrol(A6) 539 | BNE.S mt_trenoc 540 | CLR.B n_tremolopos(A6) 541 | mt_trenoc 542 | MOVE.W n_length(A6),4(A5) ; Set length 543 | MOVE.L n_start(A6),(A5) ; Set start 544 | BNE.S mt_sdmaskp 545 | CLR.L n_loopstart(A6) 546 | MOVEQ #1,D0 547 | MOVE.W D0,4(A5) 548 | MOVE.W D0,n_replen(A6) 549 | mt_sdmaskp 550 | MOVE.W n_period(A6),D0 551 | MOVE.W D0,6(A5) ; Set period 552 | MOVE.W n_dmabit(A6),D0 553 | OR.W D0,mt_DMACONtemp 554 | BRA mt_CheckMoreEfx 555 | 556 | mt_SetDMA 557 | MOVE.L A0,-(SP) 558 | MOVE.L D1,-(SP) 559 | LEA $DFF006,A0 560 | MOVEQ #7-1,D1 561 | lineloop4 562 | MOVE.B (A0),D0 563 | waiteol4 564 | CMP.B (A0),D0 565 | BEQ.B waiteol4 566 | DBRA D1,lineloop4 567 | 568 | MOVE.W mt_DMACONtemp,D0 569 | OR.W #$8000,D0 ; Set bits 570 | MOVE.W D0,$DFF096 571 | 572 | MOVEQ #7-1,D1 573 | lineloop5 574 | MOVE.B (A0),D0 575 | waiteol5 576 | CMP.B (A0),D0 577 | BEQ.B waiteol5 578 | DBRA D1,lineloop5 579 | MOVE.L (SP)+,D1 580 | MOVE.L (SP)+,A0 581 | 582 | LEA $DFF000,A5 583 | LEA mt_chan4temp,A6 584 | MOVE.L n_loopstart(A6),$D0(A5) 585 | MOVE.W n_replen(A6),$D4(A5) 586 | LEA mt_chan3temp,A6 587 | MOVE.L n_loopstart(A6),$C0(A5) 588 | MOVE.W n_replen(A6),$C4(A5) 589 | LEA mt_chan2temp,A6 590 | MOVE.L n_loopstart(A6),$B0(A5) 591 | MOVE.W n_replen(A6),$B4(A5) 592 | LEA mt_chan1temp,A6 593 | MOVE.L n_loopstart(A6),$A0(A5) 594 | MOVE.W n_replen(A6),$A4(A5) 595 | 596 | mt_dskip 597 | ADD.W #16,mt_PatternPos 598 | MOVE.B mt_PattDelTime,D0 599 | BEQ.S mt_dskpc 600 | MOVE.B D0,mt_PattDelTime2 601 | CLR.B mt_PattDelTime 602 | mt_dskpc TST.B mt_PattDelTime2 603 | BEQ.S mt_dskpa 604 | SUBQ.B #1,mt_PattDelTime2 605 | BEQ.S mt_dskpa 606 | SUB.W #16,mt_PatternPos 607 | mt_dskpa TST.B mt_PBreakFlag 608 | BEQ.S mt_nnpysk 609 | SF mt_PBreakFlag 610 | MOVEQ #0,D0 611 | MOVE.B mt_PBreakPos,D0 612 | LSL.W #4,D0 613 | MOVE.W D0,mt_PatternPos 614 | CLR.B mt_PBreakPos 615 | mt_nnpysk 616 | CMP.W #1024,mt_PatternPos 617 | BLO.S mt_NoNewPosYet 618 | mt_NextPosition 619 | MOVEQ #0,D0 620 | MOVE.B mt_PBreakPos,D0 621 | LSL.W #4,D0 622 | MOVE.W D0,mt_PatternPos 623 | CLR.B mt_PBreakPos 624 | CLR.B mt_PosJumpFlag 625 | ADDQ.B #1,mt_SongPos 626 | AND.B #$7F,mt_SongPos 627 | MOVE.B mt_SongPos,D1 628 | MOVE.L mt_SongDataPtr,A0 629 | CMP.B 950(A0),D1 630 | BLO.S mt_NoNewPosYet 631 | CLR.B mt_SongPos 632 | 633 | mt_NoNewPosYet 634 | TST.B mt_PosJumpFlag 635 | BNE.S mt_NextPosition 636 | mt_exit MOVEM.L (SP)+,D0-D7/A0-A6 637 | RTS 638 | 639 | mt_CheckEffects 640 | BSR mt_UpdateFunk 641 | MOVE.W n_cmd(A6),D0 642 | AND.W #$0FFF,D0 643 | BEQ.S mt_Return 644 | MOVE.B n_cmd(A6),D0 645 | AND.B #$0F,D0 646 | BEQ.S mt_Arpeggio 647 | CMP.B #1,D0 648 | BEQ mt_PortaUp 649 | CMP.B #2,D0 650 | BEQ mt_PortaDown 651 | CMP.B #3,D0 652 | BEQ mt_TonePortamento 653 | CMP.B #4,D0 654 | BEQ mt_Vibrato 655 | CMP.B #5,D0 656 | BEQ mt_TonePlusVolSlide 657 | CMP.B #6,D0 658 | BEQ mt_VibratoPlusVolSlide 659 | CMP.B #$E,D0 660 | BEQ mt_E_Commands 661 | SetBack MOVE.W n_period(A6),6(A5) 662 | CMP.B #7,D0 663 | BEQ mt_Tremolo 664 | CMP.B #$A,D0 665 | BEQ mt_VolumeSlide 666 | mt_Return 667 | RTS 668 | 669 | mt_PerNop 670 | MOVE.W n_period(A6),6(A5) 671 | RTS 672 | 673 | mt_Arpeggio 674 | MOVEQ #0,D0 675 | MOVE.B mt_counter,D0 676 | DIVS #3,D0 677 | SWAP D0 678 | CMP.W #1,D0 679 | BEQ.S mt_Arpeggio1 680 | CMP.W #2,D0 681 | BEQ.S mt_Arpeggio2 682 | mt_Arpeggio0 683 | MOVE.W n_period(A6),D2 684 | BRA mt_ArpeggioSet 685 | 686 | mt_Arpeggio1 687 | MOVEQ #0,D0 688 | MOVE.B n_cmdlo(A6),D0 689 | LSR.B #4,D0 690 | BRA.S mt_ArpeggioFind 691 | 692 | mt_Arpeggio2 693 | MOVEQ #0,D0 694 | MOVE.B n_cmdlo(A6),D0 695 | AND.B #15,D0 696 | mt_ArpeggioFind 697 | ADD.W D0,D0 698 | MOVEQ #0,D1 699 | MOVE.B n_finetune(A6),D1 700 | MULU #36*2,D1 701 | LEA mt_PeriodTable(PC),A0 702 | ADD.L D1,A0 703 | MOVEQ #0,D1 704 | MOVE.W n_period(A6),D1 705 | MOVEQ #36,D3 706 | mt_arploop 707 | MOVE.W (A0,D0.W),D2 708 | CMP.W (A0),D1 709 | BHS.S mt_ArpeggioSet 710 | ADDQ.L #2,A0 711 | DBRA D3,mt_arploop 712 | RTS 713 | 714 | mt_ArpeggioSet 715 | MOVE.W D2,6(A5) 716 | RTS 717 | 718 | mt_FinePortaUp 719 | TST.B mt_counter 720 | BNE.S mt_Return 721 | MOVE.B #$0F,mt_LowMask 722 | mt_PortaUp 723 | MOVEQ #0,D0 724 | MOVE.B n_cmdlo(A6),D0 725 | AND.B mt_LowMask,D0 726 | MOVE.B #$FF,mt_LowMask 727 | SUB.W D0,n_period(A6) 728 | MOVE.W n_period(A6),D0 729 | AND.W #$0FFF,D0 730 | CMP.W #$0071,D0 731 | BPL.S mt_PortaUskip 732 | AND.W #$F000,n_period(A6) 733 | OR.W #$0071,n_period(A6) 734 | mt_PortaUskip 735 | MOVE.W n_period(A6),D0 736 | AND.W #$0FFF,D0 737 | MOVE.W D0,6(A5) 738 | RTS 739 | 740 | mt_FinePortaDown 741 | TST.B mt_counter 742 | BNE mt_Return 743 | MOVE.B #$0F,mt_LowMask 744 | mt_PortaDown 745 | CLR.W D0 746 | MOVE.B n_cmdlo(A6),D0 747 | AND.B mt_LowMask,D0 748 | MOVE.B #$FF,mt_LowMask 749 | ADD.W D0,n_period(A6) 750 | MOVE.W n_period(A6),D0 751 | AND.W #$0FFF,D0 752 | CMP.W #$0358,D0 753 | BMI.S mt_PortaDskip 754 | AND.W #$F000,n_period(A6) 755 | OR.W #$0358,n_period(A6) 756 | mt_PortaDskip 757 | MOVE.W n_period(A6),D0 758 | AND.W #$0FFF,D0 759 | MOVE.W D0,6(A5) 760 | RTS 761 | 762 | mt_SetTonePorta 763 | MOVE.L A0,-(SP) 764 | MOVE.W (A6),D2 765 | AND.W #$0FFF,D2 766 | MOVEQ #0,D0 767 | MOVE.B n_finetune(A6),D0 768 | MULU #37*2,D0 769 | LEA mt_PeriodTable(PC),A0 770 | ADD.L D0,A0 771 | MOVEQ #0,D0 772 | mt_StpLoop 773 | CMP.W (A0,D0.W),D2 774 | BHS.S mt_StpFound 775 | ADDQ.W #2,D0 776 | CMP.W #37*2,D0 777 | BLO.S mt_StpLoop 778 | MOVEQ #35*2,D0 779 | mt_StpFound 780 | MOVE.B n_finetune(A6),D2 781 | AND.B #8,D2 782 | BEQ.S mt_StpGoss 783 | TST.W D0 784 | BEQ.S mt_StpGoss 785 | SUBQ.W #2,D0 786 | mt_StpGoss 787 | MOVE.W (A0,D0.W),D2 788 | MOVE.L (SP)+,A0 789 | MOVE.W D2,n_wantedperiod(A6) 790 | MOVE.W n_period(A6),D0 791 | CLR.B n_toneportdirec(A6) 792 | CMP.W D0,D2 793 | BEQ.S mt_ClearTonePorta 794 | BGE mt_Return 795 | MOVE.B #1,n_toneportdirec(A6) 796 | RTS 797 | 798 | mt_ClearTonePorta 799 | CLR.W n_wantedperiod(A6) 800 | RTS 801 | 802 | mt_TonePortamento 803 | MOVE.B n_cmdlo(A6),D0 804 | BEQ.S mt_TonePortNoChange 805 | MOVE.B D0,n_toneportspeed(A6) 806 | CLR.B n_cmdlo(A6) 807 | mt_TonePortNoChange 808 | TST.W n_wantedperiod(A6) 809 | BEQ mt_Return 810 | MOVEQ #0,D0 811 | MOVE.B n_toneportspeed(A6),D0 812 | TST.B n_toneportdirec(A6) 813 | BNE.S mt_TonePortaUp 814 | mt_TonePortaDown 815 | ADD.W D0,n_period(A6) 816 | MOVE.W n_wantedperiod(A6),D0 817 | CMP.W n_period(A6),D0 818 | BGT.S mt_TonePortaSetPer 819 | MOVE.W n_wantedperiod(A6),n_period(A6) 820 | CLR.W n_wantedperiod(A6) 821 | BRA.S mt_TonePortaSetPer 822 | 823 | mt_TonePortaUp 824 | SUB.W D0,n_period(A6) 825 | MOVE.W n_wantedperiod(A6),D0 826 | CMP.W n_period(A6),D0 827 | BLT.S mt_TonePortaSetPer 828 | MOVE.W n_wantedperiod(A6),n_period(A6) 829 | CLR.W n_wantedperiod(A6) 830 | 831 | mt_TonePortaSetPer 832 | MOVE.W n_period(A6),D2 833 | MOVE.B n_glissfunk(A6),D0 834 | AND.B #$0F,D0 835 | BEQ.S mt_GlissSkip 836 | MOVEQ #0,D0 837 | MOVE.B n_finetune(A6),D0 838 | MULU #37*2,D0 839 | LEA mt_PeriodTable(PC),A0 840 | ADD.L D0,A0 841 | MOVEQ #0,D0 842 | mt_GlissLoop 843 | CMP.W (A0,D0.W),D2 844 | BHS.S mt_GlissFound 845 | ADDQ.W #2,D0 846 | CMP.W #37*2,D0 847 | BLO.S mt_GlissLoop 848 | MOVEQ #35*2,D0 849 | mt_GlissFound 850 | MOVE.W (A0,D0.W),D2 851 | mt_GlissSkip 852 | MOVE.W D2,6(A5) ; Set period 853 | RTS 854 | 855 | mt_Vibrato 856 | MOVE.B n_cmdlo(A6),D0 857 | BEQ.S mt_Vibrato2 858 | MOVE.B n_vibratocmd(A6),D2 859 | AND.B #$0F,D0 860 | BEQ.S mt_vibskip 861 | AND.B #$F0,D2 862 | OR.B D0,D2 863 | mt_vibskip 864 | MOVE.B n_cmdlo(A6),D0 865 | AND.B #$F0,D0 866 | BEQ.S mt_vibskip2 867 | AND.B #$0F,D2 868 | OR.B D0,D2 869 | mt_vibskip2 870 | MOVE.B D2,n_vibratocmd(A6) 871 | mt_Vibrato2 872 | MOVE.B n_vibratopos(A6),D0 873 | LEA mt_VibratoTable(PC),A4 874 | LSR.W #2,D0 875 | AND.W #$001F,D0 876 | MOVEQ #0,D2 877 | MOVE.B n_wavecontrol(A6),D2 878 | AND.B #3,D2 879 | BEQ.S mt_vib_sine 880 | LSL.B #3,D0 881 | CMP.B #1,D2 882 | BEQ.S mt_vib_rampdown 883 | MOVE.B #255,D2 884 | BRA.S mt_vib_set 885 | mt_vib_rampdown 886 | TST.B n_vibratopos(A6) 887 | BPL.S mt_vib_rampdown2 888 | MOVE.B #255,D2 889 | SUB.B D0,D2 890 | BRA.S mt_vib_set 891 | mt_vib_rampdown2 892 | MOVE.B D0,D2 893 | BRA.S mt_vib_set 894 | mt_vib_sine 895 | MOVE.B (A4,D0.W),D2 896 | mt_vib_set 897 | MOVE.B n_vibratocmd(A6),D0 898 | AND.W #15,D0 899 | MULU D0,D2 900 | LSR.W #7,D2 901 | MOVE.W n_period(A6),D0 902 | TST.B n_vibratopos(A6) 903 | BMI.S mt_VibratoNeg 904 | ADD.W D2,D0 905 | BRA.S mt_Vibrato3 906 | mt_VibratoNeg 907 | SUB.W D2,D0 908 | mt_Vibrato3 909 | MOVE.W D0,6(A5) 910 | MOVE.B n_vibratocmd(A6),D0 911 | LSR.W #2,D0 912 | AND.W #$003C,D0 913 | ADD.B D0,n_vibratopos(A6) 914 | RTS 915 | 916 | mt_TonePlusVolSlide 917 | BSR mt_TonePortNoChange 918 | BRA mt_VolumeSlide 919 | 920 | mt_VibratoPlusVolSlide 921 | BSR.S mt_Vibrato2 922 | BRA mt_VolumeSlide 923 | 924 | mt_Tremolo 925 | MOVE.B n_cmdlo(A6),D0 926 | BEQ.S mt_Tremolo2 927 | MOVE.B n_tremolocmd(A6),D2 928 | AND.B #$0F,D0 929 | BEQ.S mt_treskip 930 | AND.B #$F0,D2 931 | OR.B D0,D2 932 | mt_treskip 933 | MOVE.B n_cmdlo(A6),D0 934 | AND.B #$F0,D0 935 | BEQ.S mt_treskip2 936 | AND.B #$0F,D2 937 | OR.B D0,D2 938 | mt_treskip2 939 | MOVE.B D2,n_tremolocmd(A6) 940 | mt_Tremolo2 941 | MOVE.B n_tremolopos(A6),D0 942 | LEA mt_VibratoTable(PC),A4 943 | LSR.W #2,D0 944 | AND.W #$001F,D0 945 | MOVEQ #0,D2 946 | MOVE.B n_wavecontrol(A6),D2 947 | LSR.B #4,D2 948 | AND.B #3,D2 949 | BEQ.S mt_tre_sine 950 | LSL.B #3,D0 951 | CMP.B #1,D2 952 | BEQ.S mt_tre_rampdown 953 | MOVE.B #255,D2 954 | BRA.S mt_tre_set 955 | mt_tre_rampdown 956 | TST.B n_vibratopos(A6) 957 | BPL.S mt_tre_rampdown2 958 | MOVE.B #255,D2 959 | SUB.B D0,D2 960 | BRA.S mt_tre_set 961 | mt_tre_rampdown2 962 | MOVE.B D0,D2 963 | BRA.S mt_tre_set 964 | mt_tre_sine 965 | MOVE.B (A4,D0.W),D2 966 | mt_tre_set 967 | MOVE.B n_tremolocmd(A6),D0 968 | AND.W #15,D0 969 | MULU D0,D2 970 | LSR.W #6,D2 971 | MOVEQ #0,D0 972 | MOVE.B n_volume(A6),D0 973 | TST.B n_tremolopos(A6) 974 | BMI.S mt_TremoloNeg 975 | ADD.W D2,D0 976 | BRA.S mt_Tremolo3 977 | mt_TremoloNeg 978 | SUB.W D2,D0 979 | mt_Tremolo3 980 | BPL.S mt_TremoloSkip 981 | CLR.W D0 982 | mt_TremoloSkip 983 | CMP.W #$40,D0 984 | BLS.S mt_TremoloOk 985 | MOVE.W #$40,D0 986 | mt_TremoloOk 987 | MOVE.W D0,8(A5) 988 | MOVE.B n_tremolocmd(A6),D0 989 | LSR.W #2,D0 990 | AND.W #$003C,D0 991 | ADD.B D0,n_tremolopos(A6) 992 | RTS 993 | 994 | mt_SampleOffset 995 | MOVEQ #0,D0 996 | MOVE.B n_cmdlo(A6),D0 997 | BEQ.S mt_sononew 998 | MOVE.B D0,n_sampleoffset(A6) 999 | mt_sononew 1000 | MOVE.B n_sampleoffset(A6),D0 1001 | LSL.W #7,D0 1002 | CMP.W n_length(A6),D0 1003 | BGE.S mt_sofskip 1004 | SUB.W D0,n_length(A6) 1005 | LSL.W #1,D0 1006 | ADD.L D0,n_start(A6) 1007 | RTS 1008 | mt_sofskip 1009 | MOVE.W #$0001,n_length(A6) 1010 | RTS 1011 | 1012 | mt_VolumeSlide 1013 | MOVEQ #0,D0 1014 | MOVE.B n_cmdlo(A6),D0 1015 | LSR.B #4,D0 1016 | TST.B D0 1017 | BEQ.S mt_VolSlideDown 1018 | mt_VolSlideUp 1019 | ADD.B D0,n_volume(A6) 1020 | CMP.B #$40,n_volume(A6) 1021 | BMI.S mt_vsuskip 1022 | MOVE.B #$40,n_volume(A6) 1023 | mt_vsuskip 1024 | MOVE.B n_volume(A6),D0 1025 | RTS 1026 | 1027 | mt_VolSlideDown 1028 | MOVEQ #0,D0 1029 | MOVE.B n_cmdlo(A6),D0 1030 | AND.B #$0F,D0 1031 | mt_VolSlideDown2 1032 | SUB.B D0,n_volume(A6) 1033 | BPL.S mt_vsdskip 1034 | CLR.B n_volume(A6) 1035 | mt_vsdskip 1036 | MOVE.B n_volume(A6),D0 1037 | RTS 1038 | 1039 | mt_PositionJump 1040 | MOVE.B n_cmdlo(A6),D0 1041 | SUBQ.B #1,D0 1042 | MOVE.B D0,mt_SongPos 1043 | mt_pj2 CLR.B mt_PBreakPos 1044 | ST mt_PosJumpFlag 1045 | RTS 1046 | 1047 | mt_VolumeChange 1048 | MOVEQ #0,D0 1049 | MOVE.B n_cmdlo(A6),D0 1050 | CMP.B #$40,D0 1051 | BLS.S mt_VolumeOk 1052 | MOVEQ #$40,D0 1053 | mt_VolumeOk 1054 | MOVE.B D0,n_volume(A6) 1055 | RTS 1056 | 1057 | mt_PatternBreak 1058 | MOVEQ #0,D0 1059 | MOVE.B n_cmdlo(A6),D0 1060 | MOVE.L D0,D2 1061 | LSR.B #4,D0 1062 | MULU #10,D0 1063 | AND.B #$0F,D2 1064 | ADD.B D2,D0 1065 | CMP.B #63,D0 1066 | BHI.S mt_pj2 1067 | MOVE.B D0,mt_PBreakPos 1068 | ST mt_PosJumpFlag 1069 | RTS 1070 | 1071 | mt_SetSpeed 1072 | MOVEQ #0,D0 1073 | MOVE.B 3(A6),D0 1074 | BEQ _mt_end__Fv 1075 | CMP.B #32,D0 1076 | BHS SetTempo 1077 | CLR.B mt_counter 1078 | MOVE.B D0,mt_speed 1079 | RTS 1080 | 1081 | mt_CheckMoreEfx 1082 | MOVE.B 2(A6),D0 1083 | AND.B #$0F,D0 1084 | CMP.B #$9,D0 1085 | BEQ mt_SampleOffset 1086 | CMP.B #$B,D0 1087 | BEQ mt_PositionJump 1088 | CMP.B #$D,D0 1089 | BEQ.S mt_PatternBreak 1090 | CMP.B #$E,D0 1091 | BEQ.S mt_E_Commands 1092 | CMP.B #$F,D0 1093 | BEQ.S mt_SetSpeed 1094 | CMP.B #$C,D0 1095 | BEQ mt_VolumeChange 1096 | BRA mt_PerNop 1097 | 1098 | mt_E_Commands 1099 | MOVE.B n_cmdlo(A6),D0 1100 | AND.B #$F0,D0 1101 | LSR.B #4,D0 1102 | BEQ.S mt_FilterOnOff 1103 | CMP.B #1,D0 1104 | BEQ mt_FinePortaUp 1105 | CMP.B #2,D0 1106 | BEQ mt_FinePortaDown 1107 | CMP.B #3,D0 1108 | BEQ.S mt_SetGlissControl 1109 | CMP.B #4,D0 1110 | BEQ mt_SetVibratoControl 1111 | CMP.B #5,D0 1112 | BEQ mt_SetFineTune 1113 | CMP.B #6,D0 1114 | BEQ mt_JumpLoop 1115 | CMP.B #7,D0 1116 | BEQ mt_SetTremoloControl 1117 | CMP.B #9,D0 1118 | BEQ mt_RetrigNote 1119 | CMP.B #$A,D0 1120 | BEQ mt_VolumeFineUp 1121 | CMP.B #$B,D0 1122 | BEQ mt_VolumeFineDown 1123 | CMP.B #$C,D0 1124 | BEQ mt_NoteCut 1125 | CMP.B #$D,D0 1126 | BEQ mt_NoteDelay 1127 | CMP.B #$E,D0 1128 | BEQ mt_PatternDelay 1129 | CMP.B #$F,D0 1130 | BEQ mt_FunkIt 1131 | RTS 1132 | 1133 | mt_FilterOnOff 1134 | MOVE.B n_cmdlo(A6),D0 1135 | AND.B #1,D0 1136 | ADD.B D0,D0 1137 | AND.B #$FD,$BFE001 1138 | OR.B D0,$BFE001 1139 | RTS 1140 | 1141 | mt_SetGlissControl 1142 | MOVE.B n_cmdlo(A6),D0 1143 | AND.B #$0F,D0 1144 | AND.B #$F0,n_glissfunk(A6) 1145 | OR.B D0,n_glissfunk(A6) 1146 | RTS 1147 | 1148 | mt_SetVibratoControl 1149 | MOVE.B n_cmdlo(A6),D0 1150 | AND.B #$0F,D0 1151 | AND.B #$F0,n_wavecontrol(A6) 1152 | OR.B D0,n_wavecontrol(A6) 1153 | RTS 1154 | 1155 | mt_SetFineTune 1156 | MOVE.B n_cmdlo(A6),D0 1157 | AND.B #$0F,D0 1158 | MOVE.B D0,n_finetune(A6) 1159 | RTS 1160 | 1161 | mt_JumpLoop 1162 | TST.B mt_counter 1163 | BNE mt_Return 1164 | MOVE.B n_cmdlo(A6),D0 1165 | AND.B #$0F,D0 1166 | BEQ.S mt_SetLoop 1167 | TST.B n_loopcount(A6) 1168 | BEQ.S mt_jumpcnt 1169 | SUBQ.B #1,n_loopcount(A6) 1170 | BEQ mt_Return 1171 | mt_jmploop MOVE.B n_pattpos(A6),mt_PBreakPos 1172 | ST mt_PBreakFlag 1173 | RTS 1174 | 1175 | mt_jumpcnt 1176 | MOVE.B D0,n_loopcount(A6) 1177 | BRA.S mt_jmploop 1178 | 1179 | mt_SetLoop 1180 | MOVE.W mt_PatternPos,D0 1181 | LSR.W #4,D0 1182 | AND.B #63,D0 1183 | MOVE.B D0,n_pattpos(A6) 1184 | RTS 1185 | 1186 | mt_SetTremoloControl 1187 | MOVE.B n_cmdlo(A6),D0 1188 | AND.B #$0F,D0 1189 | LSL.B #4,D0 1190 | AND.B #$0F,n_wavecontrol(A6) 1191 | OR.B D0,n_wavecontrol(A6) 1192 | RTS 1193 | 1194 | mt_RetrigNote 1195 | MOVE.L D1,-(SP) 1196 | MOVEQ #0,D0 1197 | MOVE.B n_cmdlo(A6),D0 1198 | AND.B #$0F,D0 1199 | BEQ.S mt_rtnend 1200 | MOVEQ #0,D1 1201 | MOVE.B mt_counter,D1 1202 | BNE.S mt_rtnskp 1203 | MOVE.W n_note(A6),D1 1204 | AND.W #$0FFF,D1 1205 | BNE.S mt_rtnend 1206 | MOVEQ #0,D1 1207 | MOVE.B mt_counter,D1 1208 | mt_rtnskp 1209 | DIVU D0,D1 1210 | SWAP D1 1211 | TST.W D1 1212 | BNE.S mt_rtnend 1213 | mt_DoRetrig 1214 | MOVE.W n_dmabit(A6),$DFF096 ; Channel DMA off 1215 | MOVE.L n_start(A6),(A5) ; Set sampledata pointer 1216 | MOVE.W n_length(A6),4(A5) ; Set length 1217 | MOVE.W n_period(A6),6(A5) ; Set period 1218 | 1219 | MOVE.L A0,-(SP) 1220 | LEA $DFF006,A0 1221 | MOVEQ #7-1,D1 1222 | lineloop6 1223 | MOVE.B (A0),D0 1224 | waiteol6 1225 | CMP.B (A0),D0 1226 | BEQ.B waiteol6 1227 | DBRA D1,lineloop6 1228 | 1229 | MOVE.W n_dmabit(A6),D0 1230 | BSET #15,D0 ; Set bits 1231 | MOVE.W D0,$DFF096 1232 | 1233 | MOVEQ #7-1,D1 1234 | lineloop7 1235 | MOVE.B (A0),D0 1236 | waiteol7 1237 | CMP.B (A0),D0 1238 | BEQ.B waiteol7 1239 | DBRA D1,lineloop7 1240 | MOVE.L (SP)+,A0 1241 | 1242 | MOVE.L n_loopstart(A6),(A5) 1243 | MOVE.L n_replen(A6),4(A5) 1244 | mt_rtnend 1245 | MOVE.L (SP)+,D1 1246 | RTS 1247 | 1248 | mt_VolumeFineUp 1249 | TST.B mt_counter 1250 | BNE mt_Return 1251 | MOVEQ #0,D0 1252 | MOVE.B n_cmdlo(A6),D0 1253 | AND.B #$F,D0 1254 | BRA mt_VolSlideUp 1255 | 1256 | mt_VolumeFineDown 1257 | TST.B mt_counter 1258 | BNE mt_Return 1259 | MOVEQ #0,D0 1260 | MOVE.B n_cmdlo(A6),D0 1261 | AND.B #$0F,D0 1262 | BRA mt_VolSlideDown2 1263 | 1264 | mt_NoteCut 1265 | MOVEQ #0,D0 1266 | MOVE.B n_cmdlo(A6),D0 1267 | AND.B #$0F,D0 1268 | CMP.B mt_counter,D0 1269 | BNE mt_Return 1270 | CLR.B n_volume(A6) 1271 | RTS 1272 | 1273 | mt_NoteDelay 1274 | MOVEQ #0,D0 1275 | MOVE.B n_cmdlo(A6),D0 1276 | AND.B #$0F,D0 1277 | CMP.B mt_counter,D0 1278 | BNE mt_Return 1279 | MOVE.W (A6),D0 1280 | AND.W #$0FFF,D0 1281 | BEQ mt_Return 1282 | MOVE.L D1,-(SP) 1283 | BRA mt_DoRetrig 1284 | 1285 | mt_PatternDelay 1286 | TST.B mt_counter 1287 | BNE mt_Return 1288 | MOVEQ #0,D0 1289 | MOVE.B n_cmdlo(A6),D0 1290 | AND.B #$0F,D0 1291 | TST.B mt_PattDelTime2 1292 | BNE mt_Return 1293 | ADDQ.B #1,D0 1294 | MOVE.B D0,mt_PattDelTime 1295 | RTS 1296 | 1297 | mt_FunkIt 1298 | TST.B mt_counter 1299 | BNE mt_Return 1300 | MOVE.B n_cmdlo(A6),D0 1301 | AND.B #$0F,D0 1302 | LSL.B #4,D0 1303 | AND.B #$0F,n_glissfunk(A6) 1304 | OR.B D0,n_glissfunk(A6) 1305 | TST.B D0 1306 | BEQ mt_Return 1307 | mt_UpdateFunk 1308 | MOVE.L D1,-(SP) 1309 | MOVE.L A0,-(SP) 1310 | MOVEQ #0,D0 1311 | MOVE.B n_glissfunk(A6),D0 1312 | LSR.B #4,D0 1313 | BEQ.S mt_funkend 1314 | LEA mt_FunkTable(PC),A0 1315 | MOVE.B (A0,D0.W),D0 1316 | ADD.B D0,n_funkoffset(A6) 1317 | BTST #7,n_funkoffset(A6) 1318 | BEQ.S mt_funkend 1319 | CLR.B n_funkoffset(A6) 1320 | MOVE.L n_wavestart(A6),A0 1321 | CMP.L #0,A0 1322 | BEQ.B mt_funkend 1323 | MOVE.L n_loopstart(A6),D0 1324 | MOVEQ #0,D1 1325 | MOVE.W n_replen(A6),D1 1326 | ADD.L D1,D0 1327 | ADD.L D1,D0 1328 | ADDQ.L #1,A0 1329 | CMP.L D0,A0 1330 | BLO.S mt_funkok 1331 | MOVE.L n_loopstart(A6),A0 1332 | mt_funkok 1333 | MOVE.L A0,n_wavestart(A6) 1334 | MOVEQ #-1,D0 1335 | SUB.B (A0),D0 1336 | MOVE.B D0,(A0) 1337 | mt_funkend 1338 | MOVE.L (SP)+,A0 1339 | MOVE.L (SP)+,D1 1340 | RTS 1341 | 1342 | 1343 | mt_FunkTable dc.b 0,5,6,7,8,10,11,13,16,19,22,26,32,43,64,128 1344 | 1345 | mt_VibratoTable 1346 | dc.b 0,24,49,74,97,120,141,161 1347 | dc.b 180,197,212,224,235,244,250,253 1348 | dc.b 255,253,250,244,235,224,212,197 1349 | dc.b 180,161,141,120,97,74,49,24 1350 | 1351 | mt_PeriodTable 1352 | ; Tuning 0, Normal 1353 | dc.w 856,808,762,720,678,640,604,570,538,508,480,453 1354 | dc.w 428,404,381,360,339,320,302,285,269,254,240,226 1355 | dc.w 214,202,190,180,170,160,151,143,135,127,120,113,0 1356 | ; Tuning 1 1357 | dc.w 850,802,757,715,674,637,601,567,535,505,477,450 1358 | dc.w 425,401,379,357,337,318,300,284,268,253,239,225 1359 | dc.w 213,201,189,179,169,159,150,142,134,126,119,113,0 1360 | ; Tuning 2 1361 | dc.w 844,796,752,709,670,632,597,563,532,502,474,447 1362 | dc.w 422,398,376,355,335,316,298,282,266,251,237,224 1363 | dc.w 211,199,188,177,167,158,149,141,133,125,118,112,0 1364 | ; Tuning 3 1365 | dc.w 838,791,746,704,665,628,592,559,528,498,470,444 1366 | dc.w 419,395,373,352,332,314,296,280,264,249,235,222 1367 | dc.w 209,198,187,176,166,157,148,140,132,125,118,111,0 1368 | ; Tuning 4 1369 | dc.w 832,785,741,699,660,623,588,555,524,495,467,441 1370 | dc.w 416,392,370,350,330,312,294,278,262,247,233,220 1371 | dc.w 208,196,185,175,165,156,147,139,131,124,117,110,0 1372 | ; Tuning 5 1373 | dc.w 826,779,736,694,655,619,584,551,520,491,463,437 1374 | dc.w 413,390,368,347,328,309,292,276,260,245,232,219 1375 | dc.w 206,195,184,174,164,155,146,138,130,123,116,109,0 1376 | ; Tuning 6 1377 | dc.w 820,774,730,689,651,614,580,547,516,487,460,434 1378 | dc.w 410,387,365,345,325,307,290,274,258,244,230,217 1379 | dc.w 205,193,183,172,163,154,145,137,129,122,115,109,0 1380 | ; Tuning 7 1381 | dc.w 814,768,725,684,646,610,575,543,513,484,457,431 1382 | dc.w 407,384,363,342,323,305,288,272,256,242,228,216 1383 | dc.w 204,192,181,171,161,152,144,136,128,121,114,108,0 1384 | ; Tuning -8 1385 | dc.w 907,856,808,762,720,678,640,604,570,538,508,480 1386 | dc.w 453,428,404,381,360,339,320,302,285,269,254,240 1387 | dc.w 226,214,202,190,180,170,160,151,143,135,127,120,0 1388 | ; Tuning -7 1389 | dc.w 900,850,802,757,715,675,636,601,567,535,505,477 1390 | dc.w 450,425,401,379,357,337,318,300,284,268,253,238 1391 | dc.w 225,212,200,189,179,169,159,150,142,134,126,119,0 1392 | ; Tuning -6 1393 | dc.w 894,844,796,752,709,670,632,597,563,532,502,474 1394 | dc.w 447,422,398,376,355,335,316,298,282,266,251,237 1395 | dc.w 223,211,199,188,177,167,158,149,141,133,125,118,0 1396 | ; Tuning -5 1397 | dc.w 887,838,791,746,704,665,628,592,559,528,498,470 1398 | dc.w 444,419,395,373,352,332,314,296,280,264,249,235 1399 | dc.w 222,209,198,187,176,166,157,148,140,132,125,118,0 1400 | ; Tuning -4 1401 | dc.w 881,832,785,741,699,660,623,588,555,524,494,467 1402 | dc.w 441,416,392,370,350,330,312,294,278,262,247,233 1403 | dc.w 220,208,196,185,175,165,156,147,139,131,123,117,0 1404 | ; Tuning -3 1405 | dc.w 875,826,779,736,694,655,619,584,551,520,491,463 1406 | dc.w 437,413,390,368,347,328,309,292,276,260,245,232 1407 | dc.w 219,206,195,184,174,164,155,146,138,130,123,116,0 1408 | ; Tuning -2 1409 | dc.w 868,820,774,730,689,651,614,580,547,516,487,460 1410 | dc.w 434,410,387,365,345,325,307,290,274,258,244,230 1411 | dc.w 217,205,193,183,172,163,154,145,137,129,122,115,0 1412 | ; Tuning -1 1413 | dc.w 862,814,768,725,684,646,610,575,543,513,484,457 1414 | dc.w 431,407,384,363,342,323,305,288,272,256,242,228 1415 | dc.w 216,203,192,181,171,161,152,144,136,128,121,114,0 1416 | 1417 | section __MERGED,bss 1418 | 1419 | _mt_chan1temp: 1420 | mt_chan1temp ds.w 21 1421 | _mt_chan2temp: 1422 | mt_chan2temp ds.w 21 1423 | _mt_chan3temp: 1424 | mt_chan3temp ds.w 21 1425 | _mt_chan4temp: 1426 | mt_chan4temp ds.w 21 1427 | 1428 | _mt_SampleStarts 1429 | mt_SampleStarts 1430 | ds.l 31 1431 | 1432 | _mt_data: 1433 | mt_SongDataPtr ds.l 1 1434 | _mt_speed: 1435 | mt_speed ds.b 1 1436 | mt_counter ds.b 1 1437 | _mt_SongPos 1438 | mt_SongPos ds.b 1 1439 | mt_PBreakPos ds.b 1 1440 | mt_PosJumpFlag ds.b 1 1441 | mt_PBreakFlag ds.b 1 1442 | mt_LowMask ds.b 1 1443 | mt_PattDelTime ds.b 1 1444 | mt_PattDelTime2 ds.b 1 1445 | _mt_Enable: 1446 | mt_Enable ds.b 1 1447 | _mt_PatternPos: 1448 | mt_PatternPos ds.w 1 1449 | mt_DMACONtemp ds.w 1 1450 | _mt_chan1input: 1451 | mt_chan1input: ds.l 1 1452 | _mt_chan2input: 1453 | mt_chan2input: ds.l 1 1454 | _mt_chan3input: 1455 | mt_chan3input: ds.l 1 1456 | _mt_chan4input: 1457 | mt_chan4input: ds.l 1 1458 | 1459 | end 1460 | -------------------------------------------------------------------------------- /Palette.cpp: -------------------------------------------------------------------------------- 1 | #include "Palette.h" 2 | 3 | static uint8_t fadeTable[16][16]; 4 | 5 | void Palette::initialize() 6 | { 7 | for (int fade = 1; fade < 16; fade++) { 8 | for (int value = 0; value < 16; value++) { 9 | fadeTable[fade][value] = (uint8_t)((fade * value) / 15); 10 | } 11 | } 12 | } 13 | 14 | Palette::Palette(const uint16_t* palette, uint16_t colorCount, uint16_t fade, uint16_t fadeBaseColor) : 15 | sourcePalette(0), 16 | currentPalette(0), 17 | fade_(fade), 18 | fadeBaseColor(fadeBaseColor) 19 | { 20 | if (palette) { 21 | setPalette(palette, colorCount); 22 | 23 | if (fade_ != 15) { 24 | update(); 25 | } 26 | } 27 | } 28 | 29 | Palette::~Palette() 30 | { 31 | delete[] sourcePalette; 32 | delete[] currentPalette; 33 | } 34 | 35 | void Palette::setPalette(const uint16_t* palette, uint16_t colorCount) 36 | { 37 | delete[] sourcePalette; 38 | delete[] currentPalette; 39 | 40 | sourcePalette = new uint16_t[colorCount]; 41 | currentPalette = new uint16_t[colorCount]; 42 | colorCount_ = colorCount; 43 | 44 | for (int i = 0; i < colorCount; i++) { 45 | sourcePalette[i] = palette[i]; 46 | currentPalette[i] = palette[i]; 47 | } 48 | } 49 | 50 | void Palette::setFade(uint16_t fade) 51 | { 52 | fade_ = fade; 53 | update(); 54 | } 55 | 56 | uint16_t Palette::fade() const 57 | { 58 | return fade_; 59 | } 60 | 61 | void Palette::setFadeBaseColor(uint16_t fadeBaseColor) 62 | { 63 | this->fadeBaseColor = fadeBaseColor; 64 | } 65 | 66 | uint16_t* Palette::palette() const 67 | { 68 | return currentPalette; 69 | } 70 | 71 | void Palette::update() 72 | { 73 | uint16_t baseR = fadeBaseColor >> 8; 74 | uint16_t baseG = (fadeBaseColor & 0x0f0) >> 4; 75 | uint16_t baseB = fadeBaseColor & 0x00f; 76 | for (uint16_t i = 0; i < colorCount_; i++) { 77 | uint16_t color = sourcePalette[i]; 78 | uint16_t r = color >> 8; 79 | uint16_t g = (color & 0x0f0) >> 4; 80 | uint16_t b = color & 0x00f; 81 | int16_t rDelta = r - baseR; 82 | int16_t gDelta = g - baseG; 83 | int16_t bDelta = b - baseB; 84 | uint16_t fadedR = baseR + (rDelta >= 0 ? fadeTable[fade_][rDelta] : -fadeTable[fade_][-rDelta]); 85 | uint16_t fadedG = baseG + (gDelta >= 0 ? fadeTable[fade_][gDelta] : -fadeTable[fade_][-gDelta]); 86 | uint16_t fadedB = baseB + (bDelta >= 0 ? fadeTable[fade_][bDelta] : -fadeTable[fade_][-bDelta]); 87 | currentPalette[i] = (uint16_t)((fadedR << 8) | (fadedG << 4) | fadedB); 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /Palette.h: -------------------------------------------------------------------------------- 1 | #ifndef _PALETTE_H 2 | #define _PALETTE_H 3 | 4 | #include "Platform.h" 5 | 6 | class Palette { 7 | public: 8 | static void initialize(); 9 | 10 | Palette(const uint16_t* palette = 0, uint16_t colorCount = 0, uint16_t fade = 15, uint16_t fadeBaseColor = 0x000); 11 | ~Palette(); 12 | 13 | void setPalette(const uint16_t* palette, uint16_t colorCount); 14 | void setFade(uint16_t fade); 15 | __inline uint16_t fade() const; 16 | void setFadeBaseColor(uint16_t fadeBaseColor); 17 | __inline uint16_t* palette() const; 18 | 19 | private: 20 | void update(); 21 | 22 | uint16_t* sourcePalette; 23 | uint16_t* currentPalette; 24 | uint16_t colorCount_; 25 | uint16_t fade_; 26 | uint16_t fadeBaseColor; 27 | }; 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /Platform.cpp: -------------------------------------------------------------------------------- 1 | #include "Platform.h" 2 | 3 | Platform::Platform() : 4 | quit(false) 5 | { 6 | } 7 | 8 | Platform::~Platform() 9 | { 10 | } 11 | 12 | void Platform::show() 13 | { 14 | } 15 | 16 | void Platform::chrout(uint8_t) 17 | { 18 | } 19 | 20 | void Platform::keyRepeat() 21 | { 22 | } 23 | 24 | bool Platform::isKeyOrJoystickPressed(bool) 25 | { 26 | return false; 27 | } 28 | 29 | uint16_t Platform::readJoystick(bool) 30 | { 31 | return 0; 32 | } 33 | 34 | void Platform::displayImage(Image) 35 | { 36 | } 37 | 38 | void Platform::updateTiles(uint8_t*, uint8_t*, uint8_t) 39 | { 40 | } 41 | 42 | void Platform::renderTiles(uint8_t, uint8_t, uint16_t, uint16_t, uint8_t, uint8_t) 43 | { 44 | } 45 | 46 | void Platform::renderItem(uint8_t, uint16_t, uint16_t) 47 | { 48 | } 49 | 50 | void Platform::renderKey(uint8_t, uint16_t, uint16_t) 51 | { 52 | } 53 | 54 | void Platform::renderHealth(uint8_t, uint16_t, uint16_t) 55 | { 56 | } 57 | 58 | void Platform::renderFace(uint8_t, uint16_t, uint16_t) 59 | { 60 | } 61 | 62 | void Platform::renderLiveMap(uint8_t*) 63 | { 64 | } 65 | 66 | void Platform::renderLiveMapTile(uint8_t*, uint8_t, uint8_t) 67 | { 68 | } 69 | 70 | void Platform::renderLiveMapUnits(uint8_t*, uint8_t*, uint8_t*, uint8_t*, uint8_t, bool) 71 | { 72 | } 73 | 74 | void Platform::showCursor(uint16_t, uint16_t) 75 | { 76 | } 77 | 78 | void Platform::hideCursor() 79 | { 80 | } 81 | 82 | void Platform::setCursorShape(CursorShape) 83 | { 84 | } 85 | 86 | void Platform::fillRect(uint16_t, uint16_t, uint16_t, uint16_t, uint8_t) 87 | { 88 | } 89 | 90 | void Platform::startShakeScreen() 91 | { 92 | } 93 | 94 | void Platform::shakeScreen() 95 | { 96 | } 97 | 98 | void Platform::stopShakeScreen() 99 | { 100 | } 101 | 102 | void Platform::startFadeScreen(uint16_t, uint16_t) 103 | { 104 | } 105 | 106 | void Platform::fadeScreen(uint16_t, bool) 107 | { 108 | } 109 | 110 | void Platform::stopFadeScreen() 111 | { 112 | } 113 | 114 | void Platform::playNote(uint8_t) 115 | { 116 | } 117 | 118 | void Platform::stopNote() 119 | { 120 | } 121 | 122 | void Platform::loadModule(Module) 123 | { 124 | } 125 | 126 | void Platform::playModule(Module) 127 | { 128 | } 129 | 130 | void Platform::pauseModule() 131 | { 132 | } 133 | 134 | void Platform::stopModule() 135 | { 136 | } 137 | 138 | void Platform::playSample(uint8_t) 139 | { 140 | } 141 | 142 | void Platform::stopSample() 143 | { 144 | } 145 | 146 | void Platform::renderFrame(bool) 147 | { 148 | } 149 | 150 | void Platform::waitForScreenMemoryAccess() 151 | { 152 | } 153 | 154 | void Platform::setHighlightedMenuRow(uint16_t) 155 | { 156 | } 157 | 158 | Platform* platform = 0; 159 | -------------------------------------------------------------------------------- /Platform.h: -------------------------------------------------------------------------------- 1 | #ifndef _PLATFORM_H 2 | #define _PLATFORM_H 3 | 4 | #define SCREEN_WIDTH_IN_CHARACTERS (PLATFORM_SCREEN_WIDTH / 8) 5 | #define SCREEN_HEIGHT_IN_CHARACTERS (PLATFORM_SCREEN_HEIGHT / 8) 6 | 7 | #ifndef PLATFORM_MAP_COUNT 8 | #define PLATFORM_MAP_COUNT 14 9 | #endif 10 | 11 | #ifndef PLATFORM_INTRO_OPTIONS 12 | #define PLATFORM_INTRO_OPTIONS 4 13 | #endif 14 | 15 | typedef char int8_t; 16 | typedef short int16_t; 17 | typedef long int32_t; 18 | typedef unsigned char uint8_t; 19 | typedef unsigned short uint16_t; 20 | typedef unsigned long uint32_t; 21 | typedef unsigned char bool; 22 | #define true 1 23 | #define false 0 24 | #define INT32_MAX 0x7fffffff 25 | #define INT32_MIN 0x80000000 26 | #define INT16_MAX 0x7fff 27 | #define INT16_MIN 0x8000 28 | #define INT8_MAX 0x7f 29 | #define INT8_MIN 0x80 30 | 31 | typedef uint32_t address_t; 32 | 33 | #define MIN(a, b) (((a) < (b)) ? (a) : (b)) 34 | #define MAX(a, b) (((a) > (b)) ? (a) : (b)) 35 | #define ABS(a) ((a) >= 0 ? (a) : -(a)) 36 | 37 | class Platform { 38 | public: 39 | Platform(); 40 | virtual ~Platform(); 41 | 42 | enum Map { 43 | Map01, 44 | Map02, 45 | Map03, 46 | Map04, 47 | Map05, 48 | Map06, 49 | Map07, 50 | Map08, 51 | Map09, 52 | Map10, 53 | Map11, 54 | Map12, 55 | Map13, 56 | Map14 57 | }; 58 | 59 | enum Image { 60 | ImageIntro, 61 | ImageGame, 62 | ImageGameOver 63 | }; 64 | 65 | enum Module { 66 | ModuleSoundFX, 67 | ModuleIntro, 68 | ModuleWin, 69 | ModuleLose, 70 | ModuleInGame1, 71 | ModuleInGame2, 72 | ModuleInGame3, 73 | ModuleInGame4 74 | }; 75 | 76 | enum JoystickBits { 77 | JoystickBitRight, 78 | JoystickBitLeft, 79 | JoystickBitDown, 80 | JoystickBitUp, 81 | JoystickBitRed, 82 | JoystickBitBlue, 83 | JoystickBitGreen, 84 | JoystickBitYellow, 85 | JoystickBitPlay, 86 | JoystickBitReverse, 87 | JoystickBitForward, 88 | JoystickBitExtra 89 | }; 90 | 91 | enum JoystickMask { 92 | JoystickRight = (1 << JoystickBitRight), 93 | JoystickLeft = (1 << JoystickBitLeft), 94 | JoystickDown = (1 << JoystickBitDown), 95 | JoystickUp = (1 << JoystickBitUp), 96 | JoystickRed = (1 << JoystickBitRed), 97 | JoystickBlue = (1 << JoystickBitBlue), 98 | JoystickGreen = (1 << JoystickBitGreen), 99 | JoystickYellow = (1 << JoystickBitYellow), 100 | JoystickPlay = (1 << JoystickBitPlay), 101 | JoystickReverse = (1 << JoystickBitReverse), 102 | JoystickForward = (1 << JoystickBitForward), 103 | JoystickExtra = (1 << JoystickBitExtra) 104 | }; 105 | 106 | enum CursorShape { 107 | ShapeUse, 108 | ShapeSearch, 109 | ShapeMove 110 | }; 111 | 112 | virtual uint8_t* standardControls() const = 0; 113 | virtual void setInterrupt(void (*interrupt)(void)) = 0; 114 | virtual void show(); 115 | virtual int framesPerSecond() = 0; 116 | virtual void chrout(uint8_t); 117 | virtual uint8_t readKeyboard() = 0; 118 | virtual void keyRepeat(); 119 | virtual void clearKeyBuffer() = 0; 120 | virtual bool isKeyOrJoystickPressed(bool gamepad); 121 | virtual uint16_t readJoystick(bool gamepad); 122 | virtual void loadMap(Map map, uint8_t* destination) = 0; 123 | virtual uint8_t* loadTileset() = 0; 124 | virtual void displayImage(Image image); 125 | virtual void generateTiles(uint8_t* tileData, uint8_t* tileAttributes) = 0; 126 | virtual void updateTiles(uint8_t* tileData, uint8_t* tiles, uint8_t numTiles); 127 | virtual void renderTile(uint8_t tile, uint16_t x, uint16_t y, uint8_t variant = 0, bool transparent = false) = 0; 128 | virtual void renderTiles(uint8_t backgroundTile, uint8_t foregroundTile, uint16_t x, uint16_t y, uint8_t backgroundVariant = 0, uint8_t foregroundVariant = 0); 129 | virtual void renderItem(uint8_t item, uint16_t x, uint16_t y); 130 | virtual void renderKey(uint8_t key, uint16_t x, uint16_t y); 131 | virtual void renderHealth(uint8_t health, uint16_t x, uint16_t y); 132 | virtual void renderFace(uint8_t face, uint16_t x, uint16_t y); 133 | virtual void renderLiveMap(uint8_t* map); 134 | virtual void renderLiveMapTile(uint8_t* map, uint8_t x, uint8_t y); 135 | virtual void renderLiveMapUnits(uint8_t* map, uint8_t* unitTypes, uint8_t* unitX, uint8_t* unitY, uint8_t playerColor, bool showRobots); 136 | virtual void showCursor(uint16_t x, uint16_t y); 137 | virtual void hideCursor(); 138 | virtual void setCursorShape(CursorShape shape); 139 | virtual void copyRect(uint16_t sourceX, uint16_t sourceY, uint16_t destinationX, uint16_t destinationY, uint16_t width, uint16_t height) = 0; 140 | virtual void clearRect(uint16_t x, uint16_t y, uint16_t width, uint16_t height) = 0; 141 | virtual void fillRect(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint8_t color); 142 | virtual void startShakeScreen(); 143 | virtual void shakeScreen(); 144 | virtual void stopShakeScreen(); 145 | virtual void startFadeScreen(uint16_t color, uint16_t intensity); 146 | virtual void fadeScreen(uint16_t intensity, bool immediate = true); 147 | virtual void stopFadeScreen(); 148 | virtual void writeToScreenMemory(address_t address, uint8_t value) = 0; 149 | virtual void writeToScreenMemory(address_t address, uint8_t value, uint8_t color, uint8_t yOffset) = 0; 150 | virtual void playNote(uint8_t note); 151 | virtual void stopNote(); 152 | virtual void loadModule(Module module); 153 | virtual void playModule(Module module); 154 | virtual void pauseModule(); 155 | virtual void stopModule(); 156 | virtual void playSample(uint8_t sample); 157 | virtual void stopSample(); 158 | virtual void renderFrame(bool waitForNextFrame = false); 159 | virtual void waitForScreenMemoryAccess(); 160 | virtual void setHighlightedMenuRow(uint16_t row); 161 | bool quit; 162 | }; 163 | 164 | extern Platform* platform; 165 | 166 | #endif 167 | -------------------------------------------------------------------------------- /PlatformAmiga.h: -------------------------------------------------------------------------------- 1 | #ifndef _PLATFORMAMIGA_H 2 | #define _PLATFORMAMIGA_H 3 | 4 | #define PlatformClass PlatformAmiga 5 | 6 | #include "Platform.h" 7 | 8 | struct BitMap; 9 | struct Screen; 10 | struct Window; 11 | struct Interrupt; 12 | struct IOAudio; 13 | struct MsgPort; 14 | struct BitMap; 15 | struct SimpleSprite; 16 | struct UCopList; 17 | class Palette; 18 | 19 | class PlatformAmiga : public Platform { 20 | public: 21 | PlatformAmiga(); 22 | ~PlatformAmiga(); 23 | 24 | virtual uint8_t* standardControls() const; 25 | virtual void setInterrupt(void (*interrupt)(void)); 26 | virtual void show(); 27 | virtual int framesPerSecond(); 28 | virtual uint8_t readKeyboard(); 29 | virtual void keyRepeat(); 30 | virtual void clearKeyBuffer(); 31 | virtual bool isKeyOrJoystickPressed(bool gamepad); 32 | virtual uint16_t readJoystick(bool gamepad); 33 | virtual void loadMap(Map map, uint8_t* destination); 34 | virtual uint8_t* loadTileset(); 35 | #ifdef PLATFORM_IMAGE_SUPPORT 36 | virtual void displayImage(Image image); 37 | #endif 38 | virtual void generateTiles(uint8_t* tileData, uint8_t* tileAttributes); 39 | #ifndef PLATFORM_IMAGE_BASED_TILES 40 | virtual void updateTiles(uint8_t* tileData, uint8_t* tiles, uint8_t numTiles); 41 | #endif 42 | virtual void renderTile(uint8_t tile, uint16_t x, uint16_t y, uint8_t variant, bool transparent); 43 | virtual void renderTiles(uint8_t backgroundTile, uint8_t foregroundTile, uint16_t x, uint16_t y, uint8_t backgroundVariant, uint8_t foregroundVariant); 44 | #ifdef PLATFORM_IMAGE_SUPPORT 45 | virtual void renderItem(uint8_t item, uint16_t x, uint16_t y); 46 | virtual void renderKey(uint8_t key, uint16_t x, uint16_t y); 47 | virtual void renderHealth(uint8_t health, uint16_t x, uint16_t y); 48 | virtual void renderFace(uint8_t face, uint16_t x, uint16_t y); 49 | #endif 50 | #ifdef PLATFORM_LIVE_MAP_SUPPORT 51 | virtual void renderLiveMap(uint8_t* map); 52 | virtual void renderLiveMapTile(uint8_t* map, uint8_t x, uint8_t y); 53 | virtual void renderLiveMapUnits(uint8_t* map, uint8_t* unitTypes, uint8_t* unitX, uint8_t* unitY, uint8_t playerColor, bool showRobots); 54 | #endif 55 | #ifdef PLATFORM_CURSOR_SUPPORT 56 | virtual void showCursor(uint16_t x, uint16_t y); 57 | virtual void hideCursor(); 58 | #ifdef PLATFORM_CURSOR_SHAPE_SUPPORT 59 | virtual void setCursorShape(CursorShape shape); 60 | #endif 61 | #endif 62 | virtual void copyRect(uint16_t sourceX, uint16_t sourceY, uint16_t destinationX, uint16_t destinationY, uint16_t width, uint16_t height); 63 | virtual void clearRect(uint16_t x, uint16_t y, uint16_t width, uint16_t height); 64 | virtual void fillRect(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint8_t color); 65 | #ifdef PLATFORM_HARDWARE_BASED_SHAKE_SCREEN 66 | virtual void shakeScreen(); 67 | virtual void stopShakeScreen(); 68 | #endif 69 | #ifdef PLATFORM_FADE_SUPPORT 70 | virtual void startFadeScreen(uint16_t color, uint16_t intensity); 71 | virtual void fadeScreen(uint16_t intensity, bool immediate); 72 | virtual void stopFadeScreen(); 73 | #endif 74 | virtual void writeToScreenMemory(address_t address, uint8_t value); 75 | virtual void writeToScreenMemory(address_t address, uint8_t value, uint8_t color, uint8_t yOffset); 76 | #ifdef PLATFORM_MODULE_BASED_AUDIO 77 | virtual void loadModule(Module module); 78 | virtual void playModule(Module module); 79 | virtual void pauseModule(); 80 | virtual void stopModule(); 81 | virtual void playSample(uint8_t sample); 82 | virtual void stopSample(); 83 | #else 84 | virtual void playNote(uint8_t note); 85 | virtual void stopNote(); 86 | #endif 87 | virtual void renderFrame(bool waitForNextFrame); 88 | virtual void waitForScreenMemoryAccess(); 89 | #ifdef INACTIVITY_TIMEOUT_INTRO 90 | virtual void setHighlightedMenuRow(uint16_t row); 91 | #endif 92 | 93 | private: 94 | __saveds void runVerticalBlankInterrupt(); 95 | __asm static void verticalBlankInterruptServer(); 96 | void (*interrupt)(void); 97 | uint32_t load(const char* filename, uint8_t* destination, uint32_t size); 98 | #ifdef PLATFORM_PRELOAD_SUPPORT 99 | void preloadAssets(); 100 | #endif 101 | #ifdef PLATFORM_MODULE_BASED_AUDIO 102 | void undeltaSamples(uint8_t* module, uint32_t moduleSize); 103 | void setSampleData(uint8_t* module); 104 | #endif 105 | #ifdef PLATFORM_SPRITE_SUPPORT 106 | void renderSprite(uint8_t sprite, uint16_t x, uint16_t y); 107 | #endif 108 | #ifdef PLATFORM_IMAGE_BASED_TILES 109 | void renderAnimTile(uint8_t animTile, uint16_t x, uint16_t y); 110 | #endif 111 | #ifdef PLATFORM_LIVE_MAP_SUPPORT 112 | __asm void renderLiveMapTiles(register __a1 uint8_t* map); 113 | // void renderLiveMapTiles(uint8_t* map); 114 | #endif 115 | __asm static uint16_t readCD32Pad(); 116 | __asm static void enableLowpassFilter(); 117 | __asm static void disableLowpassFilter(); 118 | #ifdef INACTIVITY_TIMEOUT_INTRO 119 | uint16_t* getUserCopperlist(); 120 | void animate(); 121 | void attract(); 122 | #endif 123 | int framesPerSecond_; 124 | uint32_t clock; 125 | uint32_t originalDirectoryLock; 126 | BitMap* screenBitmap; 127 | Screen* screen; 128 | Window* window; 129 | Interrupt* verticalBlankInterrupt; 130 | uint8_t* chipMemory; 131 | uint8_t* screenPlanes; 132 | #ifndef PLATFORM_IMAGE_BASED_TILES 133 | uint8_t* tilesPlanes; 134 | #endif 135 | uint8_t* tilesMask; 136 | uint8_t* combinedTilePlanes; 137 | #ifdef PLATFORM_MODULE_BASED_AUDIO 138 | uint8_t* moduleData; 139 | Module loadedModule; 140 | #endif 141 | #ifdef PLATFORM_IMAGE_SUPPORT 142 | Image loadedImage; 143 | #endif 144 | IOAudio* ioAudio; 145 | MsgPort* messagePort; 146 | BitMap* tilesBitMap; 147 | #ifdef PLATFORM_IMAGE_SUPPORT 148 | BitMap* facesBitMap; 149 | BitMap* itemsBitMap; 150 | BitMap* healthBitMap; 151 | #endif 152 | #ifdef PLATFORM_CURSOR_SUPPORT 153 | SimpleSprite* cursorSprite1; 154 | SimpleSprite* cursorSprite2; 155 | #endif 156 | Palette* palette; 157 | uint8_t* loadBuffer; 158 | #ifdef PLATFORM_PRELOAD_SUPPORT 159 | uint8_t* preloadedAssetBuffer; 160 | uint8_t* preloadedAssets[24]; 161 | uint32_t preloadedAssetLengths[24]; 162 | #endif 163 | #if defined(INACTIVITY_TIMEOUT_INTRO) || defined(INACTIVITY_TIMEOUT_GAME) 164 | uint16_t framesIdle; 165 | #endif 166 | #ifdef INACTIVITY_TIMEOUT_INTRO 167 | UCopList* userCopperList; 168 | Palette* highlightedMenuRowPalette; 169 | Palette* explosionPalette; 170 | int8_t highlightedMenuRowFadeDelta; 171 | int8_t explosionFadeDelta; 172 | uint8_t explosionFadeWait; 173 | uint8_t attractImageX; 174 | uint8_t attractImageY; 175 | #endif 176 | uint16_t bplcon1DefaultValue; 177 | uint8_t shakeStep; 178 | uint8_t keyToReturn; 179 | uint8_t downKey; 180 | uint8_t shift; 181 | uint16_t joystickStateToReturn; 182 | uint16_t joystickState; 183 | uint16_t pendingState; 184 | bool filterState; 185 | #ifdef PLATFORM_MODULE_BASED_AUDIO 186 | uint8_t effectChannel; 187 | #endif 188 | }; 189 | 190 | #endif 191 | -------------------------------------------------------------------------------- /PlatformAmigaAssembler.s: -------------------------------------------------------------------------------- 1 | xdef _renderLiveMapTiles__13PlatformAmigaFPUc 2 | xdef _readCD32Pad__13PlatformAmigaFv 3 | xdef _enableLowpassFilter__13PlatformAmigaFv 4 | xdef _disableLowpassFilter__13PlatformAmigaFv 5 | xdef _verticalBlankInterruptServer__13PlatformAmigaFv 6 | xref _tileLiveMap 7 | xref _liveMapToPlane1 8 | xref _liveMapToPlane3 9 | xref @runVerticalBlankInterrupt__13PlatformAmigaFv 10 | xref _addressMap 11 | 12 | SCREEN_WIDTH_IN_BYTES equ 40 13 | PLANES equ 4 14 | 15 | section code 16 | 17 | _renderLiveMapTiles__13PlatformAmigaFPUc: 18 | movem.l d2-d7/a2-a3/a5-a6,-(sp) 19 | 20 | move.l $26(a0),a2 ; screenPlanes 21 | lea PLANES*20*SCREEN_WIDTH_IN_BYTES(a2),a2 22 | lea _tileLiveMap,a3 23 | lea _liveMapToPlane1,a5 24 | lea _liveMapToPlane3,a6 25 | moveq #0,d5 26 | moveq #64-1,d7 27 | .yLoop: 28 | moveq #8-1,d6 29 | .xLoop: 30 | moveq #0,d0 31 | move.b (a1)+,d5 32 | move.b (a3,d5.w),d0 33 | lsl.w #4,d0 34 | move.b (a1)+,d5 35 | or.b (a3,d5.w),d0 36 | move.b (a5,d0.w),d1 37 | move.b (a6,d0.w),d3 38 | add.w #256,d0 39 | move.b (a5,d0.w),d2 40 | move.b (a6,d0.w),d4 41 | 42 | moveq #0,d0 43 | lsl.w #4,d1 44 | lsl.w #4,d2 45 | lsl.w #4,d3 46 | lsl.w #4,d4 47 | move.b (a1)+,d5 48 | move.b (a3,d5.w),d0 49 | lsl.w #4,d0 50 | move.b (a1)+,d5 51 | or.b (a3,d5.w),d0 52 | or.b (a5,d0.w),d1 53 | or.b (a6,d0.w),d3 54 | add.w #256,d0 55 | or.b (a5,d0.w),d2 56 | or.b (a6,d0.w),d4 57 | 58 | moveq #0,d0 59 | lsl.w #4,d1 60 | lsl.w #4,d2 61 | lsl.w #4,d3 62 | lsl.w #4,d4 63 | move.b (a1)+,d5 64 | move.b (a3,d5.w),d0 65 | lsl.w #4,d0 66 | move.b (a1)+,d5 67 | or.b (a3,d5.w),d0 68 | or.b (a5,d0.w),d1 69 | or.b (a6,d0.w),d3 70 | add.w #256,d0 71 | or.b (a5,d0.w),d2 72 | or.b (a6,d0.w),d4 73 | 74 | moveq #0,d0 75 | lsl.w #4,d1 76 | lsl.w #4,d2 77 | lsl.w #4,d3 78 | lsl.w #4,d4 79 | move.b (a1)+,d5 80 | move.b (a3,d5.w),d0 81 | lsl.w #4,d0 82 | move.b (a1)+,d5 83 | or.b (a3,d5.w),d0 84 | or.b (a5,d0.w),d1 85 | or.b (a6,d0.w),d3 86 | add.w #256,d0 87 | or.b (a5,d0.w),d2 88 | or.b (a6,d0.w),d4 89 | 90 | moveq #0,d0 91 | lsl.l #4,d1 92 | lsl.l #4,d2 93 | lsl.l #4,d3 94 | lsl.l #4,d4 95 | move.b (a1)+,d5 96 | move.b (a3,d5.w),d0 97 | lsl.w #4,d0 98 | move.b (a1)+,d5 99 | or.b (a3,d5.w),d0 100 | or.b (a5,d0.w),d1 101 | or.b (a6,d0.w),d3 102 | add.w #256,d0 103 | or.b (a5,d0.w),d2 104 | or.b (a6,d0.w),d4 105 | 106 | moveq #0,d0 107 | lsl.l #4,d1 108 | lsl.l #4,d2 109 | lsl.l #4,d3 110 | lsl.l #4,d4 111 | move.b (a1)+,d5 112 | move.b (a3,d5.w),d0 113 | lsl.w #4,d0 114 | move.b (a1)+,d5 115 | or.b (a3,d5.w),d0 116 | or.b (a5,d0.w),d1 117 | or.b (a6,d0.w),d3 118 | add.w #256,d0 119 | or.b (a5,d0.w),d2 120 | or.b (a6,d0.w),d4 121 | 122 | moveq #0,d0 123 | lsl.l #4,d1 124 | lsl.l #4,d2 125 | lsl.l #4,d3 126 | lsl.l #4,d4 127 | move.b (a1)+,d5 128 | move.b (a3,d5.w),d0 129 | lsl.w #4,d0 130 | move.b (a1)+,d5 131 | or.b (a3,d5.w),d0 132 | or.b (a5,d0.w),d1 133 | or.b (a6,d0.w),d3 134 | add.w #256,d0 135 | or.b (a5,d0.w),d2 136 | or.b (a6,d0.w),d4 137 | 138 | moveq #0,d0 139 | lsl.l #4,d1 140 | lsl.l #4,d2 141 | lsl.l #4,d3 142 | lsl.l #4,d4 143 | move.b (a1)+,d5 144 | move.b (a3,d5.w),d0 145 | lsl.w #4,d0 146 | move.b (a1)+,d5 147 | or.b (a3,d5.w),d0 148 | or.b (a5,d0.w),d1 149 | or.b (a6,d0.w),d3 150 | add.w #256,d0 151 | or.b (a5,d0.w),d2 152 | or.b (a6,d0.w),d4 153 | 154 | move.l d1,(a2)+ 155 | move.l d2,(1*SCREEN_WIDTH_IN_BYTES-4)(a2) 156 | move.l d3,(2*SCREEN_WIDTH_IN_BYTES-4)(a2) 157 | move.l d4,(3*SCREEN_WIDTH_IN_BYTES-4)(a2) 158 | move.l d1,(4*SCREEN_WIDTH_IN_BYTES-4)(a2) 159 | move.l d2,(5*SCREEN_WIDTH_IN_BYTES-4)(a2) 160 | move.l d3,(6*SCREEN_WIDTH_IN_BYTES-4)(a2) 161 | move.l d4,(7*SCREEN_WIDTH_IN_BYTES-4)(a2) 162 | dbra d6,.xLoop 163 | lea (2*PLANES*SCREEN_WIDTH_IN_BYTES-32)(a2),a2 164 | dbra d7,.yLoop 165 | 166 | movem.l (sp)+,d2-d7/a2-a3/a5-a6 167 | rts 168 | 169 | _readCD32Pad__13PlatformAmigaFv: 170 | movem.l d2-d5,-(sp) 171 | 172 | lea $bfe001,a0 173 | lea $dff000,a1 174 | move.w $16(a1),d2 ; potgor 175 | moveq #7,d3 ; CIAB_GAMEPORT1 (red) 176 | moveq #14,d4 ; 2nd button (blue) 177 | bset d3,$200(a0) ; set direction of the fire button pin 178 | bclr d3,(a0) ; clear current value of the fire button pin 179 | move.w d2,d1 180 | and.w #$cfff,d1 ; mask bits 12 and 13 out 181 | or.w #$2000,d1 ; output enable for port 2 fire button pin 182 | move.w d1,$34(a1) ; potgo 183 | 184 | moveq #0,d0 185 | moveq #10-1,d5 186 | bra.s .timingSkip 187 | .buttonLoop: 188 | tst.b (a0) 189 | tst.b (a0) 190 | .timingSkip: 191 | tst.b (a0) 192 | tst.b (a0) 193 | tst.b (a0) 194 | tst.b (a0) 195 | tst.b (a0) 196 | tst.b (a0) 197 | move.w $16(a1),d1 ; potgor 198 | bset d3,(a0) ; set and clear current value of the fire button pin 199 | bclr d3,(a0) 200 | btst d4,d1 201 | bne.s .noButton 202 | bset d5,d0 203 | .noButton: 204 | dbra d5,.buttonLoop 205 | 206 | bclr d3,$200(a0) ; reset fire button pin direction 207 | move.w d2,$34(a1) ; potgo 208 | 209 | movem.l (sp)+,d2-d5 210 | rts 211 | 212 | _enableLowpassFilter__13PlatformAmigaFv: 213 | bclr #1,$bfe001 214 | rts 215 | 216 | _disableLowpassFilter__13PlatformAmigaFv: 217 | bset #1,$bfe001 218 | rts 219 | 220 | _verticalBlankInterruptServer__13PlatformAmigaFv: 221 | movem.l d2-d7/a2-a4,-(sp) 222 | 223 | move.l a1,a0 224 | jsr @runVerticalBlankInterrupt__13PlatformAmigaFv 225 | 226 | movem.l (sp)+,d2-d7/a2-a4 227 | lea $dff000,a0 228 | moveq #0,d0 229 | rts 230 | 231 | end 232 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | Attack of the PETSCII Robots Amiga 2 | ================================== 3 | Ported by Vesa Halttunen 4 | This work is licensed under the Creative Commons Attribution 4.0 International License. To view a copy of this license, visit http://creativecommons.org/licenses/by/4.0/ or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA. 5 | 6 | About 7 | ----- 8 | - petrobots.cpp is the main game logic ported line by line from the 6502 files PETROBOTS.ASM and BACKGROUND_TASKS.ASM 9 | - Platform.h is essentially an interface with platform specific implementation classes 10 | - Various #defines starting with PLATFORM_ can be used to build a variant with different features using the same platform implementation 11 | - To port to a new platform, create a new PlatformXYZ.cpp/h implementation based on the existing ones and instantiate it in main() (petrobots.cpp) 12 | 13 | Building 14 | -------- 15 | smake 16 | cd Amiga 17 | /AmigaRobots 18 | 19 | smake clean 20 | smake -f smakefile.pet 21 | cd Amiga 22 | /PETRobots 23 | 24 | smake -f smakefile.pet clean 25 | smake -f smakefile.shareware 26 | cd Shareware 27 | ; Run setup.sh in the Shareware directory at this point 28 | /SharewareRobots 29 | 30 | smake -f smakefile.shareware clean 31 | smake -f smakefile.arcade 32 | cd Arcade 33 | ; Run setup.sh in the Arcade directory at this point 34 | /ArcadeRobots 35 | 36 | Requirements 37 | ------------ 38 | - Any classic Motorola 680x0 based Amiga with at least 512 kB of chip memory 39 | 40 | Keyboard controls 41 | ----------------- 42 | IJKL move 43 | ASDF fire 44 | Z search 45 | M move 46 | SPACE use item 47 | F1 cycle weapon 48 | F2 cycle item 49 | F6 toggle music 50 | ESC pause 51 | TAB live map 52 | SHIFT+TAB live map robots 53 | RAMIGA+Q quit 54 | 55 | Joystick controls 56 | ----------------- 57 | UP/DOWN/LEFT/RIGHT move 58 | BUTTON1+UP/DOWN/LEFT/RIGHT fire 59 | BUTTON2 use item 60 | BUTTON2+LEFT cycle item 61 | BUTTON2+RIGHT cycle weapon 62 | BUTTON2+UP move 63 | BUTTON2+DOWN search 64 | 65 | CD32 controls 66 | ------------- 67 | UP/DOWN/LEFT/RIGHT move 68 | YELLOW/RED/GREEN/BLUE fire 69 | REVERSE search 70 | FORWARD move 71 | PLAY use item 72 | PLAY+REVERSE cycle item 73 | PLAY+FORWARD cycle weapon 74 | PLAY+LEFT live map 75 | PLAY+DOWN live map robots 76 | PLAY+BLUE pause 77 | PLAY+RED toggle music 78 | 79 | Troubleshooting 80 | --------------- 81 | The hard disk installation script "Install" requires the AmigaOS tool "Installer" to be in path. It is included with AmigaOS 2.1 and above but can also be installed from Aminet (https://aminet.net/package/util/misc/Installer-43_3). The game can also be installed by manually copying the contents of the disk to the desired location, making sure to copy the Data directory as well. 82 | 83 | On systems with only 512 kilobytes of memory the game disk uses the tool "Add44k" to increase the amount of available memory. This tool is not compatible with Kickstart 3.0 and causes display corruption while the game is loading. The solution is to use a different Kickstart version, add more memory to the system or find an alternative for Add44k to be placed in s/startup-sequence. 84 | 85 | If the cursor is not (fully) visible during searching or moving objects, the game's screen is positioned too far to the left of the display. This is usually caused by the system's overscan settings. The solution is to drag the game screen to the right or to adjust the system's overscan settings so that the screen is positioned more to the right. 86 | 87 | Making of 88 | --------- 89 | The first task was to convert the 6502 assembler PET source code to C++ line by line. Even though this won't produce the most elegant high level language code it ensures that the code behaves exactly like the original does. PET KERNAL calls and memory accesses were abstracted to an interface which can be implemented for different platforms. 90 | 91 | To make initial testing and verification of the ported code easier an SDL platform implementation was written first. This allowed the game logic to be tested on a modern operating system. When eveything seemed to work it was time to write an implementation of the platform interface for the Amiga. Since the game shouldn't necessarily require every last drop of the Amiga's resources to run, the interface was implemented in an AmigaOS friendly way, multitasking in it's own AmigaOS screen. 92 | 93 | The first implementation was very naive: each write to the PET screen memory would result in copying the respective bytes from the font to the Amiga bitmap memory using the CPU. This would be highly inefficient on the Amiga, so the next step was to implement tile based rendering. Tiles would be copied in 24x24 pixel blocks using the Amiga's blitter, which on 68000 systems is much faster. Initially the tile bitmaps were generated during startup using the font and the tile data but pre-drawn bitmaps could be used just as well. After adding support for four bitplanes to get 16 colors it was already possible to switch to the tiles provided by the graphics artist. 94 | 95 | Double buffering was implemented to hide artefacts caused by modifying the screen while it's being drawn on display. However, the increase in memory consumption combined with the highly inefficient manner of switching between the buffers in an AmigaOS friendly manner called for a better approach. The bitmaps were made interleaved so that instead of the four bitplanes following each other in memory, the data for each bitplane row follows each other in memory. This way any changes to the screen memory while it's being drawn on display are limited to a small area. Each tile could be copied with a single blit, improving performance. To reduce the amount of memory required, a transparency mask was only generated for tiles requiring one. 96 | 97 | The one channel PET-like sound was replaced with a ProTracker module based sound implementation. Sound effect samples were injected programmatically to each module upon loading. The module player was modified to allow the sound effects to be triggered by the game as if they were notes in the song data. This way there was no need for a separate sound effect player or a need to make the music and sound effect playback routines aware of each other. The songs were modified to leave the fourth channel free for sound effects as often as possible. A separate "no music" module was then added which has no notes at all and allows sound effects to be played on all four channels. This completely transformed the game's audio. 98 | 99 | Support for pre-drawn graphics for the intro screen, game screen and game over screen was added. Then it was time to render the current weapon, item, keys and health using bitmap graphics. Animated player and robot sprites were implemented. Hardware based screen shaking was implemented and hardware sprites were used for the cursor. Palette fading made transitions between different screens a lot smoother. It also allowed the screen to smoothly flash when taking damage or using the EMP. Suddenly the game started to look like an Amiga game! 100 | 101 | In order to fit the game on one disk, assets had to be compressed. A hand written 68000 assembler implementation of deflate was used to decompress gzipped assets. In order to fit the game in memory, these assets had to be loaded on demand. On Amigas with only 512 kilobytes of chip memory there was no way to fit both music and sound effects into memory, so a decision was made to only support sound effects on such systems. On Amigas with more memory in-game music is loaded from disk on demand. Other assets, like the intro screen, intro music, game over screen and game over screen are loaded at startup and kept in memory to make the game over experience more pleasant. 102 | 103 | When the game was mostly complete otherwise, it was time to implement the live map. While simple in principle, Amiga does not make the implementation trivial due to its planar graphics. Instead of modifying a single byte to modify the color of a single pixel, one bit in four different bytes needs to be modified, making single pixel modifications very slow. Various chunky to planar implementations were looked into, but ultimately a custom 68000 assembler chunky to planar routine was written for drawing the entire map and an another custom implementation for manipulating the pixels relevant for each unit. The end result was a map performant enough to be usable also on 68000 systems. 104 | 105 | Last but not least joystick support was implemented. Most Amiga games only support a single button Atari style joystick. However, there are Amiga games that do support the 7 button Amiga CD32 gamepad either natively or via patches, so it made sense to add support for such a pad as well. In this mode all the game commands are available through the gamepad. Getting this code right required digging up some obscure information from forum discussions and such. Atari style joysticks can also have two buttons, so support for the second button was added to the joystick mode. This way most of the game commands are available using such a joystick as well. While not optimal, at least the game is now fully playable using a traditional joystick. 106 | 107 | TODO 108 | ---- 109 | - Add screen and map size getters in Program to allow actual screen size to be determined on startup 110 | - Amiga PAL screen size support 111 | - Amiga monitor support 112 | - Amiga command line argument / tooltype support 113 | - Render live map to a separate Amiga screen 114 | -------------------------------------------------------------------------------- /SCoptions.amiga: -------------------------------------------------------------------------------- 1 | ANSI 2 | Strict 3 | NoStackCheck 4 | StripDebug 5 | Optimize 6 | OptimizerTime 7 | OptimizerInLocal 8 | Ignore=306,315,1597 9 | NoIcons 10 | Define=PLATFORM_NAME="amiga" 11 | Define=PLATFORM_SCREEN_WIDTH=320 12 | Define=PLATFORM_SCREEN_HEIGHT=200 13 | Define=PLATFORM_MAP_WINDOW_TILES_WIDTH=11 14 | Define=PLATFORM_MAP_WINDOW_TILES_HEIGHT=7 15 | Define=PLATFORM_MODULE_BASED_AUDIO 16 | Define=PLATFORM_HARDWARE_BASED_SHAKE_SCREEN 17 | Define=PLATFORM_IMAGE_BASED_TILES 18 | Define=PLATFORM_IMAGE_SUPPORT 19 | Define=PLATFORM_SPRITE_SUPPORT 20 | Define=PLATFORM_COLOR_SUPPORT 21 | Define=PLATFORM_CURSOR_SUPPORT 22 | Define=PLATFORM_CURSOR_SHAPE_SUPPORT 23 | Define=PLATFORM_FADE_SUPPORT 24 | Define=PLATFORM_GZIP_SUPPORT 25 | Define=PLATFORM_LIVE_MAP_SUPPORT 26 | Define=PLATFORM_PRELOAD_SUPPORT 27 | Define=OPTIMIZED_MAP_RENDERING 28 | -------------------------------------------------------------------------------- /SCoptions.arcade: -------------------------------------------------------------------------------- 1 | ANSI 2 | Strict 3 | NoStackCheck 4 | StripDebug 5 | Optimize 6 | OptimizerTime 7 | OptimizerInLocal 8 | Ignore=306,315,1597 9 | NoIcons 10 | Define=PLATFORM_NAME="arcade" 11 | Define=PLATFORM_SCREEN_WIDTH=320 12 | Define=PLATFORM_SCREEN_HEIGHT=200 13 | Define=PLATFORM_MAP_WINDOW_TILES_WIDTH=11 14 | Define=PLATFORM_MAP_WINDOW_TILES_HEIGHT=7 15 | Define=PLATFORM_INTRO_OPTIONS=3 16 | Define=PLATFORM_MODULE_BASED_AUDIO 17 | Define=PLATFORM_HARDWARE_BASED_SHAKE_SCREEN 18 | Define=PLATFORM_IMAGE_BASED_TILES 19 | Define=PLATFORM_IMAGE_SUPPORT 20 | Define=PLATFORM_SPRITE_SUPPORT 21 | Define=PLATFORM_COLOR_SUPPORT 22 | Define=PLATFORM_CURSOR_SUPPORT 23 | Define=PLATFORM_CURSOR_SHAPE_SUPPORT 24 | Define=PLATFORM_FADE_SUPPORT 25 | Define=PLATFORM_GZIP_SUPPORT 26 | Define=PLATFORM_LIVE_MAP_SUPPORT 27 | Define=PLATFORM_LIVE_MAP_SINGLE_KEY 28 | Define=PLATFORM_PRELOAD_SUPPORT 29 | Define=OPTIMIZED_MAP_RENDERING 30 | Define=INACTIVITY_TIMEOUT_GAME=60 31 | Define=INACTIVITY_TIMEOUT_INTRO=15 32 | -------------------------------------------------------------------------------- /SCoptions.pet: -------------------------------------------------------------------------------- 1 | ANSI 2 | Strict 3 | NoStackCheck 4 | StripDebug 5 | Optimize 6 | OptimizerTime 7 | OptimizerInLocal 8 | Ignore=306,315,1597 9 | NoIcons 10 | Define=PLATFORM_NAME="pet" 11 | Define=PLATFORM_SCREEN_WIDTH=320 12 | Define=PLATFORM_SCREEN_HEIGHT=200 13 | Define=PLATFORM_MAP_WINDOW_TILES_WIDTH=11 14 | Define=PLATFORM_MAP_WINDOW_TILES_HEIGHT=7 15 | Define=PLATFORM_GZIP_SUPPORT 16 | -------------------------------------------------------------------------------- /SCoptions.shareware: -------------------------------------------------------------------------------- 1 | ANSI 2 | Strict 3 | NoStackCheck 4 | StripDebug 5 | Optimize 6 | OptimizerTime 7 | OptimizerInLocal 8 | Ignore=306,315,1597 9 | NoIcons 10 | Define=PLATFORM_NAME="amiga" 11 | Define=PLATFORM_SCREEN_WIDTH=320 12 | Define=PLATFORM_SCREEN_HEIGHT=200 13 | Define=PLATFORM_MAP_WINDOW_TILES_WIDTH=11 14 | Define=PLATFORM_MAP_WINDOW_TILES_HEIGHT=7 15 | Define=PLATFORM_MAP_COUNT=2 16 | Define=PLATFORM_INTRO_OPTIONS=3 17 | Define=PLATFORM_MODULE_BASED_AUDIO 18 | Define=PLATFORM_HARDWARE_BASED_SHAKE_SCREEN 19 | Define=PLATFORM_IMAGE_BASED_TILES 20 | Define=PLATFORM_IMAGE_SUPPORT 21 | Define=PLATFORM_SPRITE_SUPPORT 22 | Define=PLATFORM_COLOR_SUPPORT 23 | Define=PLATFORM_CURSOR_SUPPORT 24 | Define=PLATFORM_CURSOR_SHAPE_SUPPORT 25 | Define=PLATFORM_FADE_SUPPORT 26 | Define=PLATFORM_LIVE_MAP_SUPPORT 27 | Define=PLATFORM_PRELOAD_SUPPORT 28 | Define=OPTIMIZED_MAP_RENDERING 29 | -------------------------------------------------------------------------------- /Shareware/.gitignore: -------------------------------------------------------------------------------- 1 | Data/** 2 | -------------------------------------------------------------------------------- /Shareware/AttackOfThePETSCIIRobots.readme: -------------------------------------------------------------------------------- 1 | Short: Attack of the PETSCII Robots (Shareware) 2 | Author: dfwgreencars@gmail.com (David Murray) 3 | Uploader: vesuri@jormas.com (Vesa Halttunen) 4 | Type: game/demo 5 | Architecture: m68k-amigaos 6 | Version: Shareware 7 | 8 | Explore the vast worlds, both indoors and outdoors. Along the way you will find 9 | guns, bombs, magnets, EMP devices, and health kits, which will help you defeat 10 | the robots. You'll need to solve puzzles, sometimes using wits, other times 11 | using skill to stay alive and make it to the transporter pad. You'll get to 12 | play the 10 original maps (*), along with several bonus maps for the Amiga 13 | version. 14 | 15 | This version was designed from the ground up for the Commodore Amiga. It makes 16 | proper use of the enhanced graphics and sound capabilities of the Amiga in 17 | order to provide a better graphical experience than the preceding 8-bit 18 | versions. It also features an instant on-screen map, 16-color graphics, a 19 | 4-channel "Mod Tracker" style musical score, and even a PETSCII-only 20 | version (*) to pay homage to the original PET version. 21 | 22 | Petscii Robots will work on any Amiga with at least 512K, but does support 23 | additional RAM to provide in-game music and hard disk installation for faster 24 | loading of maps. You can play with the keyboard, joystick, or a 25 | CD32 gamepad (*). 26 | 27 | David Murray Original Game Design, assembly coding. 28 | Vesa Halttunen Amiga development 29 | Piotr Radecki Pixel art for tiles 30 | Noelle Aman MOD-Music 31 | Anders Enger Jensen Box and Manual design 32 | Brendan Carmody Original Box Art 33 | 34 | Attack of the PETSCII Robots Amiga shareware version is free to distribute. 35 | You can buy the full version at www.the8bitguy.com. 36 | Features marked with an asterisk (*) are only available in the full version. 37 | 38 | Full version includes: 39 | - all 14 levels 40 | - 4 different in-game tunes 41 | - CD32 controller support 42 | - hotkey for robot locations 43 | - customizable keyboard controls 44 | - PET graphics and sound version 45 | -------------------------------------------------------------------------------- /Shareware/setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ ! -f setup.sh ] 4 | then 5 | cd Demo 6 | fi 7 | 8 | if [ ! -f Data/IntroScreen.raw ] 9 | then 10 | mkdir -p Data 11 | for file in ../Amiga/Data/level-a.gz ../Amiga/Data/level-d.gz "../Amiga/Data/mod.metal heads.gz" ../Amiga/Data/mod.win.gz ../Amiga/Data/mod.lose.gz "../Amiga/Data/mod.metallic bop amiga.gz" "../Amiga/Data/mod.rushin in.gz" ../Amiga/Data/Game*.gz ../Arcade/Data/Intro*.gz 12 | do 13 | output=`basename "$file"` 14 | gzip -cd "$file" > "Data/${output%.gz}" 15 | done 16 | fi 17 | -------------------------------------------------------------------------------- /Sounds/SOUND_BEEP.raw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeropolis79/PETSCIIRobots-Amiga/266132967fd50eb44080d90c8221c2449daaf540/Sounds/SOUND_BEEP.raw -------------------------------------------------------------------------------- /Sounds/SOUND_BEEP2.raw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeropolis79/PETSCIIRobots-Amiga/266132967fd50eb44080d90c8221c2449daaf540/Sounds/SOUND_BEEP2.raw -------------------------------------------------------------------------------- /Sounds/SOUND_CYCLE_ITEM.raw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeropolis79/PETSCIIRobots-Amiga/266132967fd50eb44080d90c8221c2449daaf540/Sounds/SOUND_CYCLE_ITEM.raw -------------------------------------------------------------------------------- /Sounds/SOUND_CYCLE_WEAPON.raw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeropolis79/PETSCIIRobots-Amiga/266132967fd50eb44080d90c8221c2449daaf540/Sounds/SOUND_CYCLE_WEAPON.raw -------------------------------------------------------------------------------- /Sounds/SOUND_DOOR_FASTER.raw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeropolis79/PETSCIIRobots-Amiga/266132967fd50eb44080d90c8221c2449daaf540/Sounds/SOUND_DOOR_FASTER.raw -------------------------------------------------------------------------------- /Sounds/SOUND_EMP.raw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeropolis79/PETSCIIRobots-Amiga/266132967fd50eb44080d90c8221c2449daaf540/Sounds/SOUND_EMP.raw -------------------------------------------------------------------------------- /Sounds/SOUND_ERROR.raw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeropolis79/PETSCIIRobots-Amiga/266132967fd50eb44080d90c8221c2449daaf540/Sounds/SOUND_ERROR.raw -------------------------------------------------------------------------------- /Sounds/SOUND_FOUND_ITEM.raw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeropolis79/PETSCIIRobots-Amiga/266132967fd50eb44080d90c8221c2449daaf540/Sounds/SOUND_FOUND_ITEM.raw -------------------------------------------------------------------------------- /Sounds/SOUND_MAGNET2.raw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeropolis79/PETSCIIRobots-Amiga/266132967fd50eb44080d90c8221c2449daaf540/Sounds/SOUND_MAGNET2.raw -------------------------------------------------------------------------------- /Sounds/SOUND_MEDKIT.raw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeropolis79/PETSCIIRobots-Amiga/266132967fd50eb44080d90c8221c2449daaf540/Sounds/SOUND_MEDKIT.raw -------------------------------------------------------------------------------- /Sounds/SOUND_MOVE.raw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeropolis79/PETSCIIRobots-Amiga/266132967fd50eb44080d90c8221c2449daaf540/Sounds/SOUND_MOVE.raw -------------------------------------------------------------------------------- /Sounds/SOUND_PLASMA_FASTER.raw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeropolis79/PETSCIIRobots-Amiga/266132967fd50eb44080d90c8221c2449daaf540/Sounds/SOUND_PLASMA_FASTER.raw -------------------------------------------------------------------------------- /Sounds/SOUND_SHOCK.raw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeropolis79/PETSCIIRobots-Amiga/266132967fd50eb44080d90c8221c2449daaf540/Sounds/SOUND_SHOCK.raw -------------------------------------------------------------------------------- /Sounds/sounds_dsbarexp.raw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeropolis79/PETSCIIRobots-Amiga/266132967fd50eb44080d90c8221c2449daaf540/Sounds/sounds_dsbarexp.raw -------------------------------------------------------------------------------- /Sounds/sounds_dspistol.raw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeropolis79/PETSCIIRobots-Amiga/266132967fd50eb44080d90c8221c2449daaf540/Sounds/sounds_dspistol.raw -------------------------------------------------------------------------------- /Tiletool/.gitignore: -------------------------------------------------------------------------------- 1 | *.pro.user 2 | .qmake.stash 3 | Makefile 4 | Tiletool 5 | -------------------------------------------------------------------------------- /Tiletool/Tiletool.pro: -------------------------------------------------------------------------------- 1 | #------------------------------------------------- 2 | # 3 | # Project created by QtCreator 2014-10-07T23:39:45 4 | # 5 | #------------------------------------------------- 6 | 7 | QT += core 8 | 9 | TARGET = Tiletool 10 | CONFIG += console 11 | CONFIG -= app_bundle 12 | 13 | TEMPLATE = app 14 | 15 | 16 | SOURCES += main.cpp 17 | -------------------------------------------------------------------------------- /Tiletool/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | int main(int argc, char *argv[]) 11 | { 12 | QCoreApplication app(argc, argv); 13 | QTextStream standardError(stderr); 14 | 15 | // Parse command line options 16 | QCommandLineParser parser; 17 | parser.setApplicationDescription("Tiletool"); 18 | parser.addHelpOption(); 19 | parser.addVersionOption(); 20 | 21 | QStringList args; 22 | for (int i = 0; i < argc; i++) { 23 | args << argv[i]; 24 | } 25 | QCommandLineOption reverseOption(QStringList() << "r" << "reverse", QCoreApplication::translate("main", "Convert back to 16x16.")); 26 | parser.addOption(reverseOption); 27 | parser.addPositionalArgument("input", QCoreApplication::translate("main", "The name of the image to be converted.")); 28 | parser.addPositionalArgument("output", QCoreApplication::translate("main", "The basename of the converted image.")); 29 | parser.process(args); 30 | 31 | bool reverse = parser.isSet(reverseOption); 32 | 33 | const QStringList positionalArguments = parser.positionalArguments(); 34 | 35 | if (positionalArguments.count() != 2) { 36 | standardError << QCoreApplication::translate("main", "Invalid arguments") << "\n"; 37 | return 1; 38 | } 39 | 40 | QImage inputImage(positionalArguments.first()); 41 | if (inputImage.colorCount() == 0) { 42 | standardError << QCoreApplication::translate("main", "Not a paletted image") << "\n"; 43 | return 1; 44 | } 45 | 46 | standardError << QCoreApplication::translate("main", "Input image:\n"); 47 | standardError << QCoreApplication::translate("main", "Size ") << inputImage.width() << "x" << inputImage.height() << "\n"; 48 | standardError << QCoreApplication::translate("main", "Colors ") << inputImage.colorCount() << "\n"; 49 | 50 | if (reverse) { 51 | QImage outputImage(24 * 16, 24 * 16, inputImage.format()); 52 | outputImage.setColorCount(inputImage.colorCount()); 53 | outputImage.setColorTable(inputImage.colorTable()); 54 | for (int tile = 0; tile < 256; tile++) { 55 | int inputY = tile * 24; 56 | int outputX = (tile % 16) * 24; 57 | int outputY = (tile / 16) * 24; 58 | for (int y = 0; y < 24; y++) { 59 | for (int x = 0; x < 24; x++) { 60 | outputImage.setPixel(outputX + x, outputY + y, inputImage.pixelIndex(x, inputY + y)); 61 | } 62 | } 63 | } 64 | outputImage.save(positionalArguments.at(1)); 65 | 66 | } else { 67 | QImage outputImage(32, 24 * 256, inputImage.format()); 68 | outputImage.setColorCount(inputImage.colorCount()); 69 | outputImage.setColorTable(inputImage.colorTable()); 70 | for (int tile = 0; tile < 256; tile++) { 71 | int inputX = (tile % 16) * 24; 72 | int inputY = (tile / 16) * 24; 73 | int outputY = tile * 24; 74 | for (int y = 0; y < 24; y++) { 75 | for (int x = 0; x < 24; x++) { 76 | outputImage.setPixel(x, outputY + y, inputImage.pixelIndex(inputX + x, inputY + y)); 77 | } 78 | for (int x = 24; x < 32; x++) { 79 | outputImage.setPixel(x, outputY + y, 0); 80 | } 81 | } 82 | } 83 | outputImage.save(positionalArguments.at(1)); 84 | } 85 | 86 | return 0; 87 | } 88 | -------------------------------------------------------------------------------- /petrobots.h: -------------------------------------------------------------------------------- 1 | #ifndef _PETROBOTS_H 2 | #define _PETROBOTS_H 3 | 4 | #include "Platform.h" 5 | 6 | #define MAP_WINDOW_SIZE (PLATFORM_MAP_WINDOW_TILES_WIDTH * PLATFORM_MAP_WINDOW_TILES_HEIGHT) 7 | #define MAP_WINDOW_WIDTH (PLATFORM_MAP_WINDOW_TILES_WIDTH * 24) 8 | #define MAP_WINDOW_HEIGHT (PLATFORM_MAP_WINDOW_TILES_HEIGHT * 24) 9 | 10 | // MAP FILES CONSIST OF EVERYTHING FROM THIS POINT ON 11 | extern uint8_t MAP_DATA[8960]; 12 | #define UNIT_TYPE MAP_DATA // Unit type 0=none (64 bytes) 13 | #define UNIT_LOC_X (MAP_DATA + 1 * 64) // Unit X location (64 bytes) 14 | #define UNIT_LOC_Y (MAP_DATA + 2 * 64) // Unit X location (64 bytes) 15 | #define UNIT_A (MAP_DATA + 3 * 64) 16 | #define UNIT_B (MAP_DATA + 4 * 64) 17 | #define UNIT_C (MAP_DATA + 5 * 64) 18 | #define UNIT_D (MAP_DATA + 6 * 64) 19 | #define UNIT_HEALTH ((int8_t*)(MAP_DATA + 7 * 64)) // Unit health (0 to 11) (64 bytes) 20 | #define MAP (MAP_DATA + 8 * 64 + 256) // Location of MAP (8K) 21 | // END OF MAP FILE 22 | 23 | extern uint8_t* DESTRUCT_PATH; // Destruct path array (256 bytes) 24 | extern uint8_t* TILE_ATTRIB; // Tile attrib array (256 bytes) 25 | #ifndef PLATFORM_SPRITE_SUPPORT 26 | extern uint8_t* TILE_DATA_TL; // Tile character top-left (256 bytes) 27 | extern uint8_t* TILE_DATA_TM; // Tile character top-middle (256 bytes) 28 | extern uint8_t* TILE_DATA_TR; // Tile character top-right (256 bytes) 29 | extern uint8_t* TILE_DATA_ML; // Tile character middle-left (256 bytes) 30 | extern uint8_t* TILE_DATA_MM; // Tile character middle-middle (256 bytes) 31 | extern uint8_t* TILE_DATA_MR; // Tile character middle-right (256 bytes) 32 | extern uint8_t* TILE_DATA_BL; // Tile character bottom-left (256 bytes) 33 | extern uint8_t* TILE_DATA_BM; // Tile character bottom-middle (256 bytes) 34 | extern uint8_t* TILE_DATA_BR; // Tile character bottom-right (256 bytes) 35 | #endif 36 | 37 | // These arrays can go anywhere in RAM 38 | extern uint8_t UNIT_TIMER_A[64]; // Primary timer for units (64 bytes) 39 | extern uint8_t UNIT_TIMER_B[64]; // Secondary timer for units (64 bytes) 40 | extern uint8_t UNIT_TILE[32]; // Current tile assigned to unit (32 bytes) 41 | extern uint8_t EXP_BUFFER[16]; // Explosion Buffer (16 bytes) 42 | extern uint8_t MAP_PRECALC[MAP_WINDOW_SIZE]; // Stores pre-calculated objects for map window (77 bytes) 43 | extern uint8_t MAP_PRECALC_DIRECTION[MAP_WINDOW_SIZE]; // Stores pre-calculated object directions for map window (77 bytes) 44 | extern uint8_t MAP_PRECALC_TYPE[MAP_WINDOW_SIZE]; // Stores pre-calculated object types for map window (77 bytes) 45 | #ifdef OPTIMIZED_MAP_RENDERING 46 | extern uint8_t PREVIOUS_MAP_BACKGROUND[MAP_WINDOW_SIZE]; 47 | extern uint8_t PREVIOUS_MAP_FOREGROUND[MAP_WINDOW_SIZE]; 48 | extern uint8_t PREVIOUS_MAP_FOREGROUND_VARIANT[MAP_WINDOW_SIZE]; 49 | #endif 50 | 51 | // The following are the locations where the current 52 | // key controls are stored. These must be set before 53 | // the game can start. 54 | extern uint8_t KEY_CONFIG[26]; 55 | 56 | extern uint8_t TILE; // The tile number to be plotted 57 | extern uint8_t DIRECTION; // The direction of the tile to be plotted 58 | extern uint8_t WALK_FRAME; // Player walking animation frame 59 | extern uint8_t DEMATERIALIZE_FRAME; // Dematerialize animation frame 60 | extern uint8_t MAP_X; // Current X location on map 61 | extern uint8_t MAP_Y; // Current Y location on map 62 | extern uint8_t MAP_WINDOW_X; // Top left location of what is displayed in map window 63 | extern uint8_t MAP_WINDOW_Y; // Top left location of what is displayed in map window 64 | extern uint8_t DECNUM; // a decimal number to be displayed onscreen as 3 digits. 65 | extern uint8_t ATTRIB; // Tile attribute value 66 | extern uint8_t UNIT; // Current unit being processed 67 | extern uint8_t TEMP_A; // used within some routines 68 | extern uint8_t TEMP_B; // used within some routines 69 | extern uint8_t TEMP_C; // used within some routines 70 | extern uint8_t TEMP_D; // used within some routines 71 | extern uint8_t CURSOR_X; // For on-screen cursor 72 | extern uint8_t CURSOR_Y; // For on-screen cursor 73 | extern uint8_t CURSOR_ON; // Is cursor active or not? 1=yes 0=no 74 | extern uint8_t REDRAW_WINDOW; // 1=yes 0=no 75 | extern uint8_t MOVE_RESULT; // 1=Move request success, 0=fail. 76 | extern uint8_t UNIT_FIND; // 255=no unit present. 77 | extern uint8_t MOVE_TYPE; // %00000001=WALK %00000010=HOVER 78 | extern uint8_t* CUR_PATTERN; // stores the memory location of the current musical pattern being played. 79 | 80 | //extern uint8_t LSTX; // $97 Current Key Pressed: 255 = No Key 81 | extern uint8_t NDX; // $9E No. of Chars. in Keyboard Buffer (Queue) 82 | extern uint8_t* MAP_SOURCE; // $FD 83 | extern uint8_t SCREEN_MEMORY[SCREEN_WIDTH_IN_CHARACTERS * SCREEN_HEIGHT_IN_CHARACTERS]; // $8000 84 | extern bool quit; 85 | 86 | void INIT_GAME(); 87 | 88 | //extern char MAPNAME[]; 89 | extern const char* LOADMSG1; 90 | extern uint8_t KEYS; // bit0=spade bit2=heart bit3=star 91 | extern uint8_t AMMO_PISTOL; // how much ammo for the pistol 92 | extern uint8_t AMMO_PLASMA; // how many shots of the plasmagun 93 | extern uint8_t INV_BOMBS; // How many bombs do we have 94 | extern uint8_t INV_EMP; // How many EMPs do we have 95 | extern uint8_t INV_MEDKIT; // How many medkits do we have? 96 | extern uint8_t INV_MAGNET; // How many magnets do we have? 97 | extern uint8_t SELECTED_WEAPON; // 0=none 1=pistol 2=plasmagun 98 | extern uint8_t SELECTED_ITEM; // 0=none 1=bomb 2=emp 3=medkit 4=magnet 99 | extern uint8_t SELECT_TIMEOUT; // can only change weapons once it hits zero 100 | extern uint8_t ANIMATE; // 0=DISABLED 1=ENABLED 101 | extern uint8_t BIG_EXP_ACT; // 0=No explosion active 1=big explosion active 102 | extern uint8_t MAGNET_ACT; // 0=no magnet active 1=magnet active 103 | extern uint8_t PLASMA_ACT; // 0=No plasma fire active 1=plasma fire active 104 | extern uint8_t RANDOM; // used for random number generation 105 | extern uint8_t BORDER; // Used for border flash timing 106 | extern uint8_t SCREEN_SHAKE; // 1=shake 0=no shake 107 | extern uint8_t CONTROL; // 0=keyboard 1=custom keys 2=snes 108 | extern uint16_t BORDER_COLOR; // Used for border flash coloring 109 | extern char INTRO_MESSAGE[]; 110 | extern char MSG_CANTMOVE[]; 111 | extern char MSG_BLOCKED[]; 112 | extern char MSG_SEARCHING[]; 113 | extern char MSG_NOTFOUND[]; 114 | extern char MSG_FOUNDKEY[]; 115 | extern char MSG_FOUNDGUN[]; 116 | extern char MSG_FOUNDEMP[]; 117 | extern char MSG_FOUNDBOMB[]; 118 | extern char MSG_FOUNDPLAS[]; 119 | extern char MSG_FOUNDMED[]; 120 | extern char MSG_FOUNDMAG[]; 121 | extern char MSG_MUCHBET[]; 122 | extern char MSG_EMPUSED[]; 123 | extern char MSG_TERMINATED[]; 124 | extern char MSG_TRANS1[]; 125 | extern char MSG_ELEVATOR[]; 126 | extern char MSG_LEVELS[]; 127 | extern char MSG_PAUSED[]; 128 | extern char MSG_MUSICON[]; 129 | extern char MSG_MUSICOFF[]; 130 | extern uint8_t SELECTED_MAP; 131 | extern char MAP_NAMES[]; 132 | #ifndef PLATFORM_MODULE_BASED_AUDIO 133 | // THE FOLLOWING ARE USED BY THE SOUND SYSTEM* 134 | extern uint8_t TEMPO_TIMER; // used for counting down to the next tick 135 | extern uint8_t TEMPO; // How many IRQs between ticks 136 | extern uint8_t DATA_LINE; // used for playback to keep track of which line we are executing. 137 | extern uint8_t ARP_MODE; // 0=no 1=major 2=minor 3=sus4 138 | extern uint8_t CHORD_ROOT; // root note of the chord 139 | extern uint8_t SOUND_EFFECT; // FF=OFF or number of effect in progress 140 | #endif 141 | extern uint8_t MUSIC_ON; // 0=off 1=on 142 | 143 | void DISPLAY_LOAD_MESSAGE1(); 144 | void DISPLAY_LOAD_MESSAGE2(); 145 | 146 | extern char LOAD_MSG2[]; 147 | 148 | void SETUP_INTERRUPT(); 149 | void RUNIRQ(); 150 | 151 | extern uint8_t BGTIMER1; 152 | extern uint8_t BGTIMER2; 153 | extern uint8_t KEYTIMER; // Used for repeat of movement 154 | 155 | void UPDATE_GAME_CLOCK(); 156 | 157 | extern uint8_t HOURS; 158 | extern uint8_t MINUTES; 159 | extern uint8_t SECONDS; 160 | extern uint8_t CYCLES; 161 | extern uint8_t CLOCK_ACTIVE; 162 | #ifdef INACTIVITY_TIMEOUT_GAME 163 | extern uint8_t INACTIVE_SECONDS; 164 | #endif 165 | 166 | void SET_INITIAL_TIMERS(); 167 | void MAIN_GAME_LOOP(); 168 | void AFTER_MOVE_SNES(); 169 | void TOGGLE_MUSIC(); 170 | void START_IN_GAME_MUSIC(); 171 | 172 | #ifdef PLATFORM_MODULE_BASED_AUDIO 173 | extern Platform::Module LEVEL_MUSIC[]; 174 | #else 175 | extern uint8_t LEVEL_MUSIC[]; 176 | #endif 177 | 178 | void CHEATER(); 179 | bool PAUSE_GAME(); 180 | void CLEAR_KEY_BUFFER(); 181 | void USE_ITEM(); 182 | void USE_BOMB(); 183 | void USE_MAGNET(); 184 | bool BOMB_MAGNET_COMMON1(); 185 | void BOMB_MAGNET_COMMON2(); 186 | void USE_EMP(); 187 | void USE_MEDKIT(); 188 | void FIRE_UP(); 189 | void FIRE_UP_PISTOL(); 190 | void FIRE_UP_PLASMA(); 191 | void FIRE_DOWN(); 192 | void FIRE_DOWN_PISTOL(); 193 | void FIRE_DOWN_PLASMA(); 194 | void FIRE_LEFT(); 195 | void FIRE_LEFT_PISTOL(); 196 | void FIRE_LEFT_PLASMA(); 197 | void FIRE_RIGHT(); 198 | void FIRE_RIGHT_PISTOL(); 199 | void FIRE_RIGHT_PLASMA(); 200 | void AFTER_FIRE(int X); 201 | void KEY_REPEAT(bool keyDown); 202 | void AFTER_MOVE(); 203 | 204 | extern uint8_t KEY_FAST; // 0=DEFAULT STATE 205 | 206 | void SEARCH_OBJECT(); 207 | 208 | extern uint8_t SEARCHBAR; // to count how many periods to display. 209 | 210 | void CALC_COORDINATES(); 211 | void USER_SELECT_OBJECT(); 212 | void MOVE_OBJECT(); 213 | 214 | extern uint8_t MOVTEMP_O; // origin tile 215 | extern uint8_t MOVTEMP_D; // destination tile 216 | extern uint8_t MOVTEMP_X; // x-coordinate 217 | extern uint8_t MOVTEMP_Y; // y-coordinate 218 | extern uint8_t MOVTEMP_U; // unit number (255=none) 219 | extern uint8_t MOVTEMP_UX; 220 | extern uint8_t MOVTEMP_UY; 221 | 222 | void CACULATE_AND_REDRAW(); 223 | void MAP_PRE_CALCULATE(); 224 | 225 | #ifdef OPTIMIZED_MAP_RENDERING 226 | void INVALIDATE_PREVIOUS_MAP(); 227 | #endif 228 | void DRAW_MAP_WINDOW(); 229 | 230 | #ifdef PLATFORM_LIVE_MAP_SUPPORT 231 | void TOGGLE_LIVE_MAP(); 232 | void TOGGLE_LIVE_MAP_ROBOTS(); 233 | void DRAW_LIVE_MAP(); 234 | 235 | extern uint8_t LIVE_MAP_ON; 236 | extern uint8_t LIVE_MAP_ROBOTS_ON; 237 | extern uint8_t LIVE_MAP_PLAYER_BLINK; 238 | #endif 239 | 240 | void PLOT_TILE(uint16_t destination, uint16_t x, uint16_t y); 241 | void PLOT_TRANSPARENT_TILE(uint16_t destination, uint16_t x, uint16_t y); 242 | #ifndef PLATFORM_CURSOR_SUPPORT 243 | void REVERSE_TILE(); 244 | #endif 245 | void CHECK_FOR_WINDOW_REDRAW(); 246 | void DECWRITE(uint16_t destination, uint8_t color = 10); 247 | 248 | void TILE_LOAD_ROUTINE(); 249 | void MAP_LOAD_ROUTINE(); 250 | void DISPLAY_GAME_SCREEN(); 251 | 252 | extern char INTRO_OPTIONS[]; 253 | 254 | void DISPLAY_INTRO_SCREEN(); 255 | void DISPLAY_ENDGAME_SCREEN(); 256 | 257 | extern char DIFF_LEVEL_WORDS[]; 258 | 259 | void DECOMPRESS_SCREEN(uint8_t* source, uint8_t color = 10); 260 | 261 | extern uint8_t RPT; // repeat value 262 | 263 | void DISPLAY_PLAYER_HEALTH(); 264 | void CYCLE_ITEM(); 265 | void DISPLAY_ITEM(); 266 | void PRESELECT_ITEM(); 267 | void DISPLAY_TIMEBOMB(); 268 | void DISPLAY_EMP(); 269 | void DISPLAY_MEDKIT(); 270 | void DISPLAY_MAGNET(); 271 | void DISPLAY_BLANK_ITEM(); 272 | void CYCLE_WEAPON(); 273 | void DISPLAY_WEAPON(); 274 | void PRESELECT_WEAPON(); 275 | void DISPLAY_PLASMA_GUN(); 276 | void DISPLAY_PISTOL(); 277 | void DISPLAY_BLANK_WEAPON(); 278 | void DISPLAY_KEYS(); 279 | void GAME_OVER(); 280 | void GOM4(); 281 | 282 | extern uint8_t GAMEOVER1[]; 283 | extern uint8_t GAMEOVER2[]; 284 | extern uint8_t GAMEOVER3[]; 285 | 286 | void DISPLAY_WIN_LOSE(); 287 | 288 | extern char WIN_MSG[]; 289 | extern char LOS_MSG[]; 290 | 291 | void PRINT_INTRO_MESSAGE(); 292 | void PRINT_INFO(const char*); 293 | 294 | extern uint8_t PRINTX; 295 | 296 | void SCROLL_INFO(); 297 | void RESET_KEYS_AMMO(); 298 | void INTRO_SCREEN(); 299 | void START_INTRO_MUSIC(); 300 | bool EXEC_COMMAND(); 301 | void CYCLE_CONTROLS(); 302 | 303 | extern char CONTROLTEXT[]; 304 | extern uint8_t CONTROLSTART[]; 305 | 306 | void CYCLE_MAP(); 307 | void DISPLAY_MAP_NAME(); 308 | char* CALC_MAP_NAME(); 309 | void REVERSE_MENU_OPTION(bool reverse); 310 | 311 | extern uint8_t MENUY; // CURRENT MENU SELECTION 312 | typedef uint16_t menu_chart_t; 313 | extern menu_chart_t MENU_CHART[]; 314 | 315 | void CHANGE_DIFFICULTY_LEVEL(); 316 | 317 | extern uint8_t DIFF_LEVEL; // default medium 318 | extern uint8_t ROBOT_FACE[]; 319 | extern uint8_t FACE_LEVEL[]; 320 | 321 | void SET_DIFF_LEVEL(); 322 | void SET_DIFF_EASY(); 323 | void SET_DIFF_HARD(); 324 | 325 | extern uint16_t MAP_CHART[PLATFORM_MAP_WINDOW_TILES_HEIGHT]; 326 | 327 | void EMP_FLASH(); 328 | void ANIMATE_WATER(); 329 | 330 | extern uint8_t WATER_TIMER; 331 | #ifdef PLATFORM_IMAGE_BASED_TILES 332 | extern uint8_t ANIM_STATE; 333 | #else 334 | extern uint8_t WATER_TEMP1; 335 | extern uint8_t HVAC_STATE; 336 | #endif 337 | extern uint8_t CINEMA_STATE; 338 | 339 | void ELEVATOR_SELECT(); 340 | 341 | extern uint8_t ELEVATOR_MAX_FLOOR; 342 | extern uint8_t ELEVATOR_CURRENT_FLOOR; 343 | 344 | void ELEVATOR_INVERT(); 345 | void ELEVATOR_INC(); 346 | void ELEVATOR_DEC(); 347 | void ELEVATOR_FIND_XY(); 348 | void SET_CONTROLS(); 349 | 350 | extern uint8_t STANDARD_CONTROLS[]; 351 | 352 | void SET_CUSTOM_KEYS(); 353 | 354 | extern uint8_t KEYS_DEFINED; // DEFAULT 0 355 | 356 | void PET_SCREEN_SHAKE(); 357 | void PET_BORDER_FLASH(); 358 | 359 | extern uint8_t FLASH_STATE; 360 | #ifndef PLATFORM_IMAGE_SUPPORT 361 | extern uint8_t OUCH1[]; 362 | extern uint8_t OUCH2[]; 363 | extern uint8_t OUCH3[]; 364 | #endif 365 | 366 | void DEMATERIALIZE(); 367 | void ANIMATE_PLAYER(); 368 | void PLAY_SOUND(int); 369 | 370 | #ifndef PLATFORM_MODULE_BASED_AUDIO 371 | extern uint8_t* PATTERN_TEMP; 372 | extern uint8_t DATA_LINE_TEMP; 373 | extern uint8_t TEMPO_TEMP; 374 | 375 | extern uint8_t* SOUND_LIBRARY[]; 376 | 377 | void MUSIC_ROUTINE(); 378 | #endif 379 | void STOP_SONG(); 380 | void BACKGROUND_TASKS(); 381 | 382 | extern void (*AI_ROUTINE_CHART[])(void); 383 | 384 | void DUMMY_ROUTINE(); 385 | void WATER_RAFT_LR(); 386 | void RAFT_DELETE(); 387 | void RAFT_PLOT(); 388 | void MAGNETIZED_ROBOT(); 389 | void GENERATE_RANDOM_NUMBER(); 390 | void MAGNET(); 391 | void DEAD_ROBOT(); 392 | void UP_DOWN_ROLLERBOT(); 393 | void LEFT_RIGHT_ROLLERBOT(); 394 | void ROLLERBOT_FIRE_DETECT(); 395 | void ROLLERBOT_AFTER_FIRE(uint8_t unit, uint8_t tile); 396 | void ROLLERBOT_ANIMATE(); 397 | void TRANSPORTER_PAD(); 398 | void TRANS_PLAYER_PRESENT(); 399 | void TRANS_ACTIVE(); 400 | void TIME_BOMB(); 401 | void BIG_EXP_PHASE1(); 402 | void BEX1_NORTH(); 403 | void BEX1_SOUTH(); 404 | void BEX1_EAST(); 405 | void BEX1_WEST(); 406 | void BEX1_NE(); 407 | void BEX1_NW(); 408 | void BEX1_SE(); 409 | void BEX1_SW(); 410 | void BEX_PART1(); 411 | bool BEX_PART2(); 412 | void BEX_PART3(); 413 | void BEXCEN(); 414 | void BIG_EXP_PHASE2(); 415 | void RESTORE_TILE(); 416 | void TRASH_COMPACTOR(); 417 | void DRAW_TRASH_COMPACTOR(); 418 | extern uint8_t TCPIECE1; 419 | extern uint8_t TCPIECE2; 420 | extern uint8_t TCPIECE3; 421 | extern uint8_t TCPIECE4; 422 | void WATER_DROID(); 423 | void PISTOL_FIRE_UP(); 424 | void PISTOL_FIRE_DOWN(); 425 | void PISTOL_FIRE_LEFT(); 426 | void PISTOL_FIRE_RIGHT(); 427 | void DEACTIVATE_WEAPON(); 428 | void PISTOL_AI_COMMON(); 429 | void ALTER_AI(); 430 | void INFLICT_DAMAGE(); 431 | void SMALL_EXPLOSION(); 432 | void HOVER_ATTACK(); 433 | void CREATE_PLAYER_EXPLOSION(); 434 | void EVILBOT(); 435 | void AI_DOOR(); 436 | extern void (*AIDB[])(void); 437 | void DOOR_OPEN_A(); 438 | void DOOR_OPEN_B(); 439 | void DOOR_OPEN_FULL(); 440 | void DOOR_CLOSE_A(); 441 | void DOOR_CLOSE_B(); 442 | void DOOR_CLOSE_FULL(); 443 | void DRAW_VERTICAL_DOOR(); 444 | void DRAW_HORIZONTAL_DOOR(); 445 | extern uint8_t DOORPIECE1; 446 | extern uint8_t DOORPIECE2; 447 | extern uint8_t DOORPIECE3; 448 | void ROBOT_ATTACK_RANGE(); 449 | void DOOR_CHECK_PROXIMITY(); 450 | extern uint8_t PROX_DETECT; 451 | void ELEVATOR(); 452 | extern void (*ELDB[])(void); 453 | void ELEV_OPEN_A(); 454 | void ELEV_OPEN_B(); 455 | void ELEV_OPEN_FULL(); 456 | void ELEV_CLOSE_A(); 457 | void ELEV_CLOSE_B(); 458 | void ELEV_CLOSE_FULL(); 459 | void ELEVATOR_PANEL(); 460 | void PLOT_TILE_TO_MAP(); 461 | void GET_TILE_FROM_MAP(); 462 | void LEFT_RIGHT_DROID(); 463 | void UP_DOWN_DROID(); 464 | void HOVERBOT_ANIMATE(uint8_t X); 465 | void REQUEST_WALK_RIGHT(); 466 | void REQUEST_WALK_LEFT(); 467 | void REQUEST_WALK_DOWN(); 468 | void REQUEST_WALK_UP(); 469 | void CHECK_FOR_UNIT(); 470 | void CHECK_FOR_HIDDEN_UNIT(); 471 | 472 | #ifndef PLATFORM_IMAGE_SUPPORT 473 | extern uint8_t INTRO_TEXT[]; 474 | extern uint8_t SCR_TEXT[]; 475 | extern uint8_t SCR_ENDGAME[]; 476 | #endif 477 | extern uint8_t SCR_CUSTOM_KEYS[]; 478 | extern char CINEMA_MESSAGE[]; 479 | #ifndef PLATFORM_IMAGE_SUPPORT 480 | extern uint8_t WEAPON1A[]; 481 | extern uint8_t WEAPON1B[]; 482 | extern uint8_t WEAPON1C[]; 483 | extern uint8_t WEAPON1D[]; 484 | extern uint8_t PISTOL1A[]; 485 | extern uint8_t PISTOL1B[]; 486 | extern uint8_t PISTOL1C[]; 487 | extern uint8_t PISTOL1D[]; 488 | extern uint8_t TBOMB1A[]; 489 | extern uint8_t TBOMB1B[]; 490 | extern uint8_t TBOMB1C[]; 491 | extern uint8_t TBOMB1D[]; 492 | extern uint8_t EMP1A[]; 493 | extern uint8_t EMP1B[]; 494 | extern uint8_t EMP1C[]; 495 | extern uint8_t EMP1D[]; 496 | extern uint8_t MAG1A[]; 497 | extern uint8_t MAG1B[]; 498 | extern uint8_t MAG1C[]; 499 | extern uint8_t MAG1D[]; 500 | extern uint8_t MED1A[]; 501 | extern uint8_t MED1B[]; 502 | extern uint8_t MED1C[]; 503 | extern uint8_t MED1D[]; 504 | #endif 505 | #ifndef PLATFORM_MODULE_BASED_AUDIO 506 | extern uint8_t NOTE_FREQ[]; 507 | extern uint8_t NOTE_OCTAVE[]; 508 | extern uint8_t SND_EXPLOSION[]; 509 | extern uint8_t SND_MEDKIT[]; 510 | extern uint8_t SND_EMP[]; 511 | extern uint8_t SND_MAGNET[]; 512 | extern uint8_t SND_SHOCK[]; 513 | extern uint8_t SND_MOVE_OBJ[]; 514 | extern uint8_t SND_PLASMA[]; 515 | extern uint8_t SND_PISTOL[]; 516 | extern uint8_t SND_ITEM_FOUND[]; 517 | extern uint8_t SND_ERROR[]; 518 | extern uint8_t SND_CYCLE_WEAPON[]; 519 | extern uint8_t SND_CYCLE_ITEM[]; 520 | extern uint8_t SND_DOOR[]; 521 | extern uint8_t SND_MENU_BEEP[]; 522 | extern uint8_t SND_SHORT_BEEP[]; 523 | extern uint8_t INTRO_MUSIC[]; 524 | extern uint8_t WIN_MUSIC[]; 525 | extern uint8_t LOSE_MUSIC[]; 526 | extern uint8_t IN_GAME_MUSIC1[]; 527 | extern uint8_t IN_GAME_MUSIC2[]; 528 | extern uint8_t IN_GAME_MUSIC3[]; 529 | #endif 530 | 531 | void convertToPETSCII(char* string); 532 | void writeToScreenMemory(address_t address, uint8_t value, uint8_t color = 10, uint8_t yOffset = 0); 533 | 534 | #endif 535 | -------------------------------------------------------------------------------- /smakefile: -------------------------------------------------------------------------------- 1 | CFLAGS=WITH SCoptions.amiga 2 | OBJECTS=petrobots.o Platform.o PlatformAmiga.o PlatformAmigaAssembler.o ungzip.o Palette.o PT2.3F_replay_cia.o Tileset.o C64Font.o Faces.o Tiles.o AnimTiles.o Sprites.o SpritesMask.o Items.o Keys.o Health.o SoundFXModule.o SoundExplosion.o SoundMedkit.o SoundEMP.o SoundMagnet.o SoundShock.o SoundMove.o SoundPlasma.o SoundPistol.o SoundItemFound.o SoundError.o SoundCycleWeapon.o SoundCycleItem.o SoundDoor.o SoundMenuBeep.o SoundShortBeep.o SquareWave.o 3 | 4 | all: AmigaRobots DecompressData 5 | 6 | AmigaRobots: $(OBJECTS) 7 | sc LINK TO AmigaRobots NOICONS WITH << 8 | $(OBJECTS) 9 | < 10 | 11 | DecompressData: DecompressData.o ungzip.o 12 | sc LINK TO DecompressData NOICONS WITH << 13 | DecompressData.o ungzip.o 14 | < 15 | 16 | petrobots.o: petrobots.cpp 17 | Platform.o: Platform.cpp 18 | PlatformAmiga.o: PlatformAmiga.cpp 19 | PlatformAmigaAssembler.o: PlatformAmigaAssembler.s 20 | ungzip.o: ungzip.s 21 | Palette.o: Palette.cpp 22 | PT2.3F_replay_cia.o: PT2.3F_replay_cia.s 23 | Tileset.o: tileset.amiga 24 | Bin2Hunk tileset.amiga Tileset.o NAME _tileset HUNK data 25 | C64Font.o: Amiga/C64Font.raw 26 | Bin2Hunk Amiga/C64Font.raw C64Font.o NAME _fontPlanes HUNK data 27 | Faces.o: Amiga/Faces.raw 28 | Bin2Hunk Amiga/Faces.raw Faces.o NAME _facesPlanes CHIP 29 | Tiles.o: Amiga/Tiles.raw 30 | Bin2Hunk Amiga/Tiles.raw Tiles.o NAME _tilesPlanes CHIP 31 | AnimTiles.o: Amiga/AnimTiles.raw 32 | Bin2Hunk Amiga/AnimTiles.raw AnimTiles.o NAME _animTilesPlanes CHIP 33 | Sprites.o: Amiga/Sprites.raw 34 | Bin2Hunk Amiga/Sprites.raw Sprites.o NAME _spritesPlanes CHIP 35 | SpritesMask.o: Amiga/SpritesMask.raw 36 | Bin2Hunk Amiga/SpritesMask.raw SpritesMask.o NAME _spritesMask CHIP 37 | Items.o: Amiga/Items.raw 38 | Bin2Hunk Amiga/Items.raw Items.o NAME _itemsPlanes CHIP 39 | Keys.o: Amiga/Keys.raw 40 | Bin2Hunk Amiga/Keys.raw Keys.o NAME _keysPlanes HUNK data 41 | Health.o: Amiga/Health.raw 42 | Bin2Hunk Amiga/Health.raw Health.o NAME _healthPlanes CHIP 43 | SoundFXModule.o: Music/mod.soundfx 44 | Bin2Hunk Music/mod.soundfx SoundFXModule.o NAME _soundFXModule CHIP 45 | SoundExplosion.o: Sounds/sounds_dsbarexp.raw 46 | Bin2Hunk Sounds/sounds_dsbarexp.raw SoundExplosion.o NAME _soundExplosion CHIP 47 | SoundMedkit.o: Sounds/SOUND_MEDKIT.raw 48 | Bin2Hunk Sounds/SOUND_MEDKIT.raw SoundMedkit.o NAME _soundMedkit CHIP 49 | SoundEMP.o: Sounds/SOUND_EMP.raw 50 | Bin2Hunk Sounds/SOUND_EMP.raw SoundEMP.o NAME _soundEMP CHIP 51 | SoundMagnet.o: Sounds/SOUND_MAGNET2.raw 52 | Bin2Hunk Sounds/SOUND_MAGNET2.raw SoundMagnet.o NAME _soundMagnet CHIP 53 | SoundShock.o: Sounds/SOUND_SHOCK.raw 54 | Bin2Hunk Sounds/SOUND_SHOCK.raw SoundShock.o NAME _soundShock CHIP 55 | SoundMove.o: Sounds/SOUND_MOVE.raw 56 | Bin2Hunk Sounds/SOUND_MOVE.raw SoundMove.o NAME _soundMove CHIP 57 | SoundPlasma.o: Sounds/SOUND_PLASMA_FASTER.raw 58 | Bin2Hunk Sounds/SOUND_PLASMA_FASTER.raw SoundPlasma.o NAME _soundPlasma CHIP 59 | SoundPistol.o: Sounds/sounds_dspistol.raw 60 | Bin2Hunk Sounds/sounds_dspistol.raw SoundPistol.o NAME _soundPistol CHIP 61 | SoundItemFound.o: Sounds/SOUND_FOUND_ITEM.raw 62 | Bin2Hunk Sounds/SOUND_FOUND_ITEM.raw SoundItemFound.o NAME _soundItemFound CHIP 63 | SoundError.o: Sounds/SOUND_ERROR.raw 64 | Bin2Hunk Sounds/SOUND_ERROR.raw SoundError.o NAME _soundError CHIP 65 | SoundCycleWeapon.o: Sounds/SOUND_CYCLE_WEAPON.raw 66 | Bin2Hunk Sounds/SOUND_CYCLE_WEAPON.raw SoundCycleWeapon.o NAME _soundCycleWeapon CHIP 67 | SoundCycleItem.o: Sounds/SOUND_CYCLE_ITEM.raw 68 | Bin2Hunk Sounds/SOUND_CYCLE_ITEM.raw SoundCycleItem.o NAME _soundCycleItem CHIP 69 | SoundDoor.o: Sounds/SOUND_DOOR_FASTER.raw 70 | Bin2Hunk Sounds/SOUND_DOOR_FASTER.raw SoundDoor.o NAME _soundDoor CHIP 71 | SoundMenuBeep.o: Sounds/SOUND_BEEP2.raw 72 | Bin2Hunk Sounds/SOUND_BEEP2.raw SoundMenuBeep.o NAME _soundMenuBeep CHIP 73 | SoundShortBeep.o: Sounds/SOUND_BEEP.raw 74 | Bin2Hunk Sounds/SOUND_BEEP.raw SoundShortBeep.o NAME _soundShortBeep CHIP 75 | SquareWave.o: Amiga/SquareWave.raw 76 | Bin2Hunk Amiga/SquareWave.raw SquareWave.o NAME _squareWave CHIP 77 | DecompressData.o: DecompressData.c 78 | 79 | clean: 80 | delete $(OBJECTS) DecompressData.o AmigaRobots AmigaRobots.lnk DecompressData DecompressData.lnk 81 | -------------------------------------------------------------------------------- /smakefile.arcade: -------------------------------------------------------------------------------- 1 | CFLAGS=WITH SCoptions.arcade 2 | OBJECTS=petrobots.o Platform.o PlatformAmiga.o PlatformAmigaAssembler.o ungzip.o Palette.o PT2.3F_replay_cia.o Tileset.o C64Font.o Faces.o Tiles.o AnimTiles.o Sprites.o SpritesMask.o Items.o Keys.o Health.o Attract1.o Attract2.o Attract3.o SoundFXModule.o SoundExplosion.o SoundMedkit.o SoundEMP.o SoundMagnet.o SoundShock.o SoundMove.o SoundPlasma.o SoundPistol.o SoundItemFound.o SoundError.o SoundCycleWeapon.o SoundCycleItem.o SoundDoor.o SoundMenuBeep.o SoundShortBeep.o SquareWave.o 3 | 4 | all: ArcadeRobots 5 | 6 | ArcadeRobots: $(OBJECTS) 7 | sc LINK TO ArcadeRobots NOICONS WITH << 8 | $(OBJECTS) 9 | < 10 | 11 | petrobots.o: petrobots.cpp 12 | Platform.o: Platform.cpp 13 | PlatformAmiga.o: PlatformAmiga.cpp 14 | PlatformAmigaAssembler.o: PlatformAmigaAssembler.s 15 | ungzip.o: ungzip.s 16 | Palette.o: Palette.cpp 17 | PT2.3F_replay_cia.o: PT2.3F_replay_cia.s 18 | Tileset.o: tileset.amiga 19 | Bin2Hunk tileset.amiga Tileset.o NAME _tileset HUNK data 20 | C64Font.o: Amiga/C64Font.raw 21 | Bin2Hunk Amiga/C64Font.raw C64Font.o NAME _fontPlanes HUNK data 22 | Faces.o: Amiga/Faces.raw 23 | Bin2Hunk Amiga/Faces.raw Faces.o NAME _facesPlanes CHIP 24 | Tiles.o: Amiga/Tiles.raw 25 | Bin2Hunk Amiga/Tiles.raw Tiles.o NAME _tilesPlanes CHIP 26 | AnimTiles.o: Amiga/AnimTiles.raw 27 | Bin2Hunk Amiga/AnimTiles.raw AnimTiles.o NAME _animTilesPlanes CHIP 28 | Sprites.o: Amiga/Sprites.raw 29 | Bin2Hunk Amiga/Sprites.raw Sprites.o NAME _spritesPlanes CHIP 30 | SpritesMask.o: Amiga/SpritesMask.raw 31 | Bin2Hunk Amiga/SpritesMask.raw SpritesMask.o NAME _spritesMask CHIP 32 | Items.o: Amiga/Items.raw 33 | Bin2Hunk Amiga/Items.raw Items.o NAME _itemsPlanes CHIP 34 | Keys.o: Amiga/Keys.raw 35 | Bin2Hunk Amiga/Keys.raw Keys.o NAME _keysPlanes HUNK data 36 | Health.o: Amiga/Health.raw 37 | Bin2Hunk Amiga/Health.raw Health.o NAME _healthPlanes CHIP 38 | Attract1.o: Arcade/Attract1.raw 39 | Bin2Hunk Arcade/Attract1.raw Attract1.o NAME _attract1Planes HUNK data 40 | Attract2.o: Arcade/Attract2.raw 41 | Bin2Hunk Arcade/Attract2.raw Attract2.o NAME _attract2Planes HUNK data 42 | Attract3.o: Arcade/Attract3.raw 43 | Bin2Hunk Arcade/Attract3.raw Attract3.o NAME _attract3Planes HUNK data 44 | SoundFXModule.o: Music/mod.soundfx 45 | Bin2Hunk Music/mod.soundfx SoundFXModule.o NAME _soundFXModule CHIP 46 | SoundExplosion.o: Sounds/sounds_dsbarexp.raw 47 | Bin2Hunk Sounds/sounds_dsbarexp.raw SoundExplosion.o NAME _soundExplosion CHIP 48 | SoundMedkit.o: Sounds/SOUND_MEDKIT.raw 49 | Bin2Hunk Sounds/SOUND_MEDKIT.raw SoundMedkit.o NAME _soundMedkit CHIP 50 | SoundEMP.o: Sounds/SOUND_EMP.raw 51 | Bin2Hunk Sounds/SOUND_EMP.raw SoundEMP.o NAME _soundEMP CHIP 52 | SoundMagnet.o: Sounds/SOUND_MAGNET2.raw 53 | Bin2Hunk Sounds/SOUND_MAGNET2.raw SoundMagnet.o NAME _soundMagnet CHIP 54 | SoundShock.o: Sounds/SOUND_SHOCK.raw 55 | Bin2Hunk Sounds/SOUND_SHOCK.raw SoundShock.o NAME _soundShock CHIP 56 | SoundMove.o: Sounds/SOUND_MOVE.raw 57 | Bin2Hunk Sounds/SOUND_MOVE.raw SoundMove.o NAME _soundMove CHIP 58 | SoundPlasma.o: Sounds/SOUND_PLASMA_FASTER.raw 59 | Bin2Hunk Sounds/SOUND_PLASMA_FASTER.raw SoundPlasma.o NAME _soundPlasma CHIP 60 | SoundPistol.o: Sounds/sounds_dspistol.raw 61 | Bin2Hunk Sounds/sounds_dspistol.raw SoundPistol.o NAME _soundPistol CHIP 62 | SoundItemFound.o: Sounds/SOUND_FOUND_ITEM.raw 63 | Bin2Hunk Sounds/SOUND_FOUND_ITEM.raw SoundItemFound.o NAME _soundItemFound CHIP 64 | SoundError.o: Sounds/SOUND_ERROR.raw 65 | Bin2Hunk Sounds/SOUND_ERROR.raw SoundError.o NAME _soundError CHIP 66 | SoundCycleWeapon.o: Sounds/SOUND_CYCLE_WEAPON.raw 67 | Bin2Hunk Sounds/SOUND_CYCLE_WEAPON.raw SoundCycleWeapon.o NAME _soundCycleWeapon CHIP 68 | SoundCycleItem.o: Sounds/SOUND_CYCLE_ITEM.raw 69 | Bin2Hunk Sounds/SOUND_CYCLE_ITEM.raw SoundCycleItem.o NAME _soundCycleItem CHIP 70 | SoundDoor.o: Sounds/SOUND_DOOR_FASTER.raw 71 | Bin2Hunk Sounds/SOUND_DOOR_FASTER.raw SoundDoor.o NAME _soundDoor CHIP 72 | SoundMenuBeep.o: Sounds/SOUND_BEEP2.raw 73 | Bin2Hunk Sounds/SOUND_BEEP2.raw SoundMenuBeep.o NAME _soundMenuBeep CHIP 74 | SoundShortBeep.o: Sounds/SOUND_BEEP.raw 75 | Bin2Hunk Sounds/SOUND_BEEP.raw SoundShortBeep.o NAME _soundShortBeep CHIP 76 | SquareWave.o: Amiga/SquareWave.raw 77 | Bin2Hunk Amiga/SquareWave.raw SquareWave.o NAME _squareWave CHIP 78 | 79 | clean: 80 | delete $(OBJECTS) ArcadeRobots ArcadeRobots.lnk 81 | -------------------------------------------------------------------------------- /smakefile.pet: -------------------------------------------------------------------------------- 1 | CFLAGS=WITH SCoptions.pet 2 | OBJECTS=petrobots.o Platform.o PlatformAmiga.o PlatformAmigaAssembler.o ungzip.o Palette.o Tileset.o PETFont.o SquareWave.o 3 | 4 | all: PETRobots 5 | 6 | PETRobots: $(OBJECTS) 7 | sc LINK TO PETRobots NOICONS WITH << 8 | $(OBJECtS) 9 | < 10 | 11 | petrobots.o: petrobots.cpp 12 | Platform.o: Platform.cpp 13 | PlatformAmiga.o: PlatformAmiga.cpp 14 | PlatformAmigaAssembler.o: PlatformAmigaAssembler.s 15 | ungzip.o: ungzip.s 16 | Palette.o: Palette.cpp 17 | Tileset.o: tileset.pet 18 | Bin2Hunk tileset.pet Tileset.o NAME _tileset HUNK data 19 | PETFont.o: Amiga/PETFont.raw 20 | Bin2Hunk Amiga/PETFont.raw PETFont.o NAME _fontPlanes HUNK data 21 | SquareWave.o: Amiga/SquareWave.raw 22 | Bin2Hunk Amiga/SquareWave.raw SquareWave.o NAME _squareWave CHIP 23 | 24 | clean: 25 | delete $(OBJECTS) PETRobots PETRobots.lnk 26 | -------------------------------------------------------------------------------- /smakefile.shareware: -------------------------------------------------------------------------------- 1 | CFLAGS=WITH SCoptions.demo 2 | OBJECTS=petrobots.o Platform.o PlatformAmiga.o PlatformAmigaAssembler.o Palette.o PT2.3F_replay_cia.o Tileset.o C64Font.o Faces.o Tiles.o AnimTiles.o Sprites.o SpritesMask.o Items.o Keys.o Health.o SoundFXModule.o SoundExplosion.o SoundMedkit.o SoundEMP.o SoundMagnet.o SoundShock.o SoundMove.o SoundPlasma.o SoundPistol.o SoundItemFound.o SoundError.o SoundCycleWeapon.o SoundCycleItem.o SoundDoor.o SoundMenuBeep.o SoundShortBeep.o SquareWave.o 3 | 4 | all: SharewareRobots 5 | 6 | SharewareRobots: $(OBJECTS) 7 | sc LINK TO SharewareRobots NOICONS WITH << 8 | $(OBJECTS) 9 | < 10 | 11 | petrobots.o: petrobots.cpp 12 | Platform.o: Platform.cpp 13 | PlatformAmiga.o: PlatformAmiga.cpp 14 | PlatformAmigaAssembler.o: PlatformAmigaAssembler.s 15 | Palette.o: Palette.cpp 16 | PT2.3F_replay_cia.o: PT2.3F_replay_cia.s 17 | Tileset.o: tileset.amiga 18 | Bin2Hunk tileset.amiga Tileset.o NAME _tileset HUNK data 19 | C64Font.o: Amiga/C64Font.raw 20 | Bin2Hunk Amiga/C64Font.raw C64Font.o NAME _fontPlanes HUNK data 21 | Faces.o: Amiga/Faces.raw 22 | Bin2Hunk Amiga/Faces.raw Faces.o NAME _facesPlanes CHIP 23 | Tiles.o: Amiga/Tiles.raw 24 | Bin2Hunk Amiga/Tiles.raw Tiles.o NAME _tilesPlanes CHIP 25 | AnimTiles.o: Amiga/AnimTiles.raw 26 | Bin2Hunk Amiga/AnimTiles.raw AnimTiles.o NAME _animTilesPlanes CHIP 27 | Sprites.o: Amiga/Sprites.raw 28 | Bin2Hunk Amiga/Sprites.raw Sprites.o NAME _spritesPlanes CHIP 29 | SpritesMask.o: Amiga/SpritesMask.raw 30 | Bin2Hunk Amiga/SpritesMask.raw SpritesMask.o NAME _spritesMask CHIP 31 | Items.o: Amiga/Items.raw 32 | Bin2Hunk Amiga/Items.raw Items.o NAME _itemsPlanes CHIP 33 | Keys.o: Amiga/Keys.raw 34 | Bin2Hunk Amiga/Keys.raw Keys.o NAME _keysPlanes HUNK data 35 | Health.o: Amiga/Health.raw 36 | Bin2Hunk Amiga/Health.raw Health.o NAME _healthPlanes CHIP 37 | SoundFXModule.o: Music/mod.soundfx 38 | Bin2Hunk Music/mod.soundfx SoundFXModule.o NAME _soundFXModule CHIP 39 | SoundExplosion.o: Sounds/sounds_dsbarexp.raw 40 | Bin2Hunk Sounds/sounds_dsbarexp.raw SoundExplosion.o NAME _soundExplosion CHIP 41 | SoundMedkit.o: Sounds/SOUND_MEDKIT.raw 42 | Bin2Hunk Sounds/SOUND_MEDKIT.raw SoundMedkit.o NAME _soundMedkit CHIP 43 | SoundEMP.o: Sounds/SOUND_EMP.raw 44 | Bin2Hunk Sounds/SOUND_EMP.raw SoundEMP.o NAME _soundEMP CHIP 45 | SoundMagnet.o: Sounds/SOUND_MAGNET2.raw 46 | Bin2Hunk Sounds/SOUND_MAGNET2.raw SoundMagnet.o NAME _soundMagnet CHIP 47 | SoundShock.o: Sounds/SOUND_SHOCK.raw 48 | Bin2Hunk Sounds/SOUND_SHOCK.raw SoundShock.o NAME _soundShock CHIP 49 | SoundMove.o: Sounds/SOUND_MOVE.raw 50 | Bin2Hunk Sounds/SOUND_MOVE.raw SoundMove.o NAME _soundMove CHIP 51 | SoundPlasma.o: Sounds/SOUND_PLASMA_FASTER.raw 52 | Bin2Hunk Sounds/SOUND_PLASMA_FASTER.raw SoundPlasma.o NAME _soundPlasma CHIP 53 | SoundPistol.o: Sounds/sounds_dspistol.raw 54 | Bin2Hunk Sounds/sounds_dspistol.raw SoundPistol.o NAME _soundPistol CHIP 55 | SoundItemFound.o: Sounds/SOUND_FOUND_ITEM.raw 56 | Bin2Hunk Sounds/SOUND_FOUND_ITEM.raw SoundItemFound.o NAME _soundItemFound CHIP 57 | SoundError.o: Sounds/SOUND_ERROR.raw 58 | Bin2Hunk Sounds/SOUND_ERROR.raw SoundError.o NAME _soundError CHIP 59 | SoundCycleWeapon.o: Sounds/SOUND_CYCLE_WEAPON.raw 60 | Bin2Hunk Sounds/SOUND_CYCLE_WEAPON.raw SoundCycleWeapon.o NAME _soundCycleWeapon CHIP 61 | SoundCycleItem.o: Sounds/SOUND_CYCLE_ITEM.raw 62 | Bin2Hunk Sounds/SOUND_CYCLE_ITEM.raw SoundCycleItem.o NAME _soundCycleItem CHIP 63 | SoundDoor.o: Sounds/SOUND_DOOR_FASTER.raw 64 | Bin2Hunk Sounds/SOUND_DOOR_FASTER.raw SoundDoor.o NAME _soundDoor CHIP 65 | SoundMenuBeep.o: Sounds/SOUND_BEEP2.raw 66 | Bin2Hunk Sounds/SOUND_BEEP2.raw SoundMenuBeep.o NAME _soundMenuBeep CHIP 67 | SoundShortBeep.o: Sounds/SOUND_BEEP.raw 68 | Bin2Hunk Sounds/SOUND_BEEP.raw SoundShortBeep.o NAME _soundShortBeep CHIP 69 | SquareWave.o: Amiga/SquareWave.raw 70 | Bin2Hunk Amiga/SquareWave.raw SquareWave.o NAME _squareWave CHIP 71 | 72 | clean: 73 | delete $(OBJECTS) SharewareRobots SharewareRobots.lnk 74 | -------------------------------------------------------------------------------- /tileset.amiga: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeropolis79/PETSCIIRobots-Amiga/266132967fd50eb44080d90c8221c2449daaf540/tileset.amiga -------------------------------------------------------------------------------- /tileset.pet: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeropolis79/PETSCIIRobots-Amiga/266132967fd50eb44080d90c8221c2449daaf540/tileset.pet -------------------------------------------------------------------------------- /ungzip.h: -------------------------------------------------------------------------------- 1 | #ifndef _UNGZIP_H 2 | #define _UNGZIP_H 3 | 4 | __asm int ungzip(register __a0 void* input, register __a1 void* output); 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /ungzip.s: -------------------------------------------------------------------------------- 1 | xdef _ungzip__FPvPv 2 | 3 | GZIP_MAGIC equ $1f8b 4 | DEFLATED equ 8 5 | CONTINUATION_BIT equ 1 6 | EXTRA_FIELD_BIT equ 2 7 | ORIG_NAME_BIT equ 3 8 | COMMENT_BIT equ 4 9 | ENCRYPTED_BIT equ 5 10 | RESERVED1_BIT equ 6 11 | RESERVED2_BIT equ 7 12 | 13 | MAXBITS equ 15 ; maximum bits in a code 14 | MAXLCODES equ 286 ; maximum number of literal/length codes 15 | MAXDCODES equ 30 ; maximum number of distance codes 16 | MAXCODES equ (MAXLCODES+MAXDCODES) ; maximum codes lengths to read 17 | FIXLCODES equ 288 ; number of fixed literal/length codes 18 | 19 | fixed_lencnt equ 0 20 | fixed_lensym equ fixed_lencnt+(MAXBITS+1)*2 21 | fixed_distcnt equ fixed_lensym+FIXLCODES*2 22 | fixed_distsym equ fixed_distcnt+(MAXBITS+1)*2 23 | fixed_lengths equ fixed_distsym+MAXDCODES*2 24 | 25 | dynamic_lengths equ 0 26 | dynamic_lencnt equ dynamic_lengths+MAXCODES*2 27 | dynamic_lensym equ dynamic_lencnt+(MAXBITS+1)*2 28 | dynamic_distcnt equ dynamic_lensym+MAXLCODES*2 29 | dynamic_distsym equ dynamic_distcnt+(MAXBITS+1)*2 30 | 31 | huffman_count equ 0 32 | huffman_symbol equ 4 33 | 34 | codes_lens equ 0 35 | codes_lext equ 29*2 36 | codes_dists equ codes_lext+29*2 37 | codes_dext equ codes_dists+30*2 38 | 39 | section code 40 | 41 | _ungzip__FPvPv: 42 | move.l a1,output 43 | bsr get_method 44 | tst.w d0 45 | bpl .unzip 46 | rts 47 | 48 | .unzip: bsr inflate 49 | rts 50 | 51 | ; In: a0 = input buffer 52 | ; Out: d0 = method or error code 53 | get_method: 54 | move.l d1,-(sp) 55 | move.w (a0)+,d0 ; magic 56 | cmp.w #GZIP_MAGIC,d0 57 | beq.s .gzip 58 | moveq #-16,d0 59 | bra.s .get_method_done 60 | .gzip: move.b (a0)+,d0 ; method 61 | cmp.b #DEFLATED,d0 62 | beq.s .deflated 63 | moveq #-17,d0 64 | bra.s .get_method_done 65 | .deflated: 66 | move.b (a0)+,d0 ; flags 67 | btst #ENCRYPTED_BIT,d0 68 | beq.s .not_encrypted 69 | moveq #-18,d0 70 | bra.s .get_method_done 71 | .not_encrypted: 72 | btst #CONTINUATION_BIT,d0 73 | beq.s .not_continuation 74 | moveq #-19,d0 75 | bra.s .get_method_done 76 | .not_continuation: 77 | btst #RESERVED1_BIT,d0 78 | bne.s .reserved 79 | btst #RESERVED2_BIT,d0 80 | beq.s .not_reserved 81 | .reserved: 82 | moveq #-20,d0 83 | bra.s .get_method_done 84 | .not_reserved: 85 | addq #6,a0 ; stamp, extra flags, os type 86 | btst #EXTRA_FIELD_BIT,d0 87 | beq.s .no_extra_field 88 | move.w (a0)+,d1 89 | add.w d1,a0 90 | .no_extra_field: 91 | btst #ORIG_NAME_BIT,d0 92 | beq.s .no_orig_name 93 | .name: tst.b (a0)+ 94 | bne.s .name 95 | .no_orig_name: 96 | btst #COMMENT_BIT,d0 97 | beq.s .no_comment 98 | .comment: 99 | tst.b (a0)+ 100 | bne.s .comment 101 | .no_comment: 102 | moveq #DEFLATED,d0 103 | .get_method_done: 104 | move.l (sp)+,d1 105 | rts 106 | 107 | ; In: a0 = input buffer 108 | ; In: a1 = output buffer 109 | ; Out: d0 = error code 110 | inflate: 111 | move.l d1,-(sp) 112 | clr.l bitbuf 113 | clr.l bitcnt 114 | 115 | .inflate_loop: 116 | moveq #1,d0 117 | bsr bits 118 | move.l d0,d1 ; one if last block 119 | 120 | moveq #2,d0 121 | bsr bits ; block type 0..3 122 | 123 | tst.w d0 124 | bne.s .not_stored 125 | bsr stored 126 | bra.s .next 127 | 128 | .not_stored: 129 | cmp.w #1,d0 130 | bne.s .not_fixed 131 | bsr fixed 132 | bra.s .next 133 | 134 | .not_fixed: 135 | cmp.w #2,d0 136 | bne.s .not_dynamic 137 | bsr dynamic 138 | bra.s .next 139 | 140 | .not_dynamic: 141 | moveq #-1,d0 142 | bra.s .inflate_done 143 | 144 | .next: tst.w d1 145 | beq.s .inflate_loop 146 | moveq #0,d0 147 | .inflate_done: 148 | move.l (sp)+,d1 149 | rts 150 | 151 | ; In: a0 = buffer 152 | ; In: d0 = need 153 | ; Out: d0 = need bits from buffer 154 | bits: movem.l d1-d4,-(sp) 155 | 156 | move.l bitbuf,d1 ; load at least need bits into val 157 | move.l bitcnt,d3 158 | .bits_loop: 159 | cmp.l d0,d3 160 | bge.s .bits_done 161 | moveq #0,d2 162 | move.b (a0)+,d2 ; load eight bits 163 | move.l d3,d4 164 | lsl.l d4,d2 165 | or.l d2,d1 166 | addq #8,d3 167 | bra.s .bits_loop 168 | 169 | .bits_done: 170 | move.l d1,d2 ; drop need bits and update buffer, always zero to seven bits left 171 | lsr.l d0,d2 172 | move.l d2,bitbuf 173 | sub.l d0,d3 174 | move.l d3,bitcnt 175 | 176 | moveq #1,d2 ; return need bits, zeroing the bits above that 177 | lsl.l d0,d2 178 | subq #1,d2 179 | and.l d2,d1 180 | move.l d1,d0 181 | 182 | movem.l (sp)+,d1-d4 183 | rts 184 | 185 | ; In: a0 = input buffer 186 | ; In: a1 = output buffer 187 | ; Out: d0 = error code 188 | stored: move.l d1,-(sp) 189 | clr.l bitbuf ; discard leftover bits from current byte (assumes s->bitcnt < 8) 190 | clr.l bitcnt 191 | 192 | move.b 1(a0),d0 193 | lsl.w #8,d0 194 | move.b (a0),d0 195 | move.b 3(a0),d1 196 | lsl.w #8,d1 197 | move.b 2(a0),d1 198 | addq #4,a0 199 | not.w d1 200 | cmp.w d0,d1 201 | beq.s .stored_ok 202 | moveq #-2,d0 203 | bra.s .stored_done 204 | 205 | .stored_ok: 206 | subq #1,d0 207 | bmi.s .stored_none_left 208 | .stored_loop: 209 | move.b (a0)+,(a1)+ 210 | dbra d0,.stored_loop 211 | 212 | .stored_none_left: 213 | moveq #0,d0 214 | .stored_done: 215 | move.l (sp)+,d1 216 | rts 217 | 218 | ; In: a0 = input buffer 219 | ; In: a1 = output buffer 220 | ; Out: d0 = error code 221 | fixed: tst.b virgin 222 | beq.w .not_virgin 223 | 224 | ; init lencode and distcode structure pointers (must be done before calling construct) 225 | lea codes_data,a2 226 | move.l a2,lencode+huffman_count 227 | move.l a2,lencode+huffman_symbol 228 | move.l a2,distcode+huffman_count 229 | move.l a2,distcode+huffman_symbol 230 | add.l #fixed_lencnt,lencode+huffman_count 231 | add.l #fixed_lensym,lencode+huffman_symbol 232 | add.l #fixed_distcnt,distcode+huffman_count 233 | add.l #fixed_distsym,distcode+huffman_symbol 234 | 235 | ; literal/length table 236 | add.w #fixed_lengths,a2 237 | move.w #144-1,d7 238 | .fixed_loop1: 239 | move.w #8,(a2)+ 240 | dbra d7,.fixed_loop1 241 | moveq #256-144-1,d7 242 | .fixed_loop2: 243 | move.w #9,(a2)+ 244 | dbra d7,.fixed_loop2 245 | moveq #280-256-1,d7 246 | .fixed_loop3: 247 | move.w #7,(a2)+ 248 | dbra d7,.fixed_loop3 249 | moveq #FIXLCODES-280-1,d7 250 | .fixed_loop4: 251 | move.w #8,(a2)+ 252 | dbra d7,.fixed_loop4 253 | 254 | movem.l a0-a1,-(sp) 255 | lea lencode,a0 256 | lea codes_data,a1 257 | add.w #fixed_lengths,a1 258 | move.l #FIXLCODES,d0 259 | bsr construct 260 | movem.l (sp)+,a0-a1 261 | 262 | ; distance table 263 | lea codes_data,a2 264 | add.w #fixed_lengths,a2 265 | moveq #MAXDCODES-1,d7 266 | .fixed_loop5: 267 | move.w #5,(a2)+ 268 | dbra d7,.fixed_loop5 269 | 270 | movem.l a0-a1,-(sp) 271 | lea distcode,a0 272 | lea codes_data,a1 273 | add.w #fixed_lengths,a1 274 | moveq #MAXDCODES,d0 275 | bsr construct 276 | movem.l (sp)+,a0-a1 277 | 278 | clr.b virgin 279 | 280 | .not_virgin: 281 | ; decode data until end-of-block code 282 | lea lencode,a2 283 | lea distcode,a3 284 | bsr codes 285 | rts 286 | 287 | ; In: a0 = input buffer 288 | ; In: a1 = output buffer 289 | ; Out: d0 = error code 290 | dynamic: 291 | movem.l d1-d7/a2-a4,-(sp) 292 | 293 | ; init structure pointers 294 | lea lencode,a2 295 | lea codes_data,a3 296 | move.l a3,lencode+huffman_count 297 | move.l a3,lencode+huffman_symbol 298 | move.l a3,distcode+huffman_count 299 | move.l a3,distcode+huffman_symbol 300 | add.l #dynamic_lencnt,lencode+huffman_count 301 | add.l #dynamic_lensym,lencode+huffman_symbol 302 | add.l #dynamic_distcnt,distcode+huffman_count 303 | add.l #dynamic_distsym,distcode+huffman_symbol 304 | add.w #dynamic_lengths,a3 305 | 306 | ; get number of lengths in each table, check lengths 307 | moveq #5,d0 308 | bsr bits 309 | add.w #257,d0 310 | cmp.w #MAXLCODES,d0 311 | ble.s .nlen_ok 312 | moveq #-3,d0 ; bad count 313 | bra.w .dynamic_done 314 | .nlen_ok: 315 | move.w d0,d1 ; nlen 316 | 317 | moveq #5,d0 318 | bsr bits 319 | addq #1,d0 320 | cmp.w #MAXDCODES,d0 321 | ble.s .ndist_ok 322 | moveq #-3,d0 ; bad count 323 | bra.w .dynamic_done 324 | .ndist_ok: 325 | move.w d0,d2 ; ndist 326 | 327 | moveq #4,d0 328 | bsr bits 329 | addq #4,d0 330 | move.w d0,d3 ; ncode 331 | 332 | ; read code length code lengths (really), missing lengths are zero 333 | lea order,a4 334 | moveq #0,d4 335 | moveq #0,d7 336 | .dynamic_loop1: 337 | moveq #3,d0 338 | bsr bits 339 | move.b (a4,d7.w),d4 340 | move.w d0,(a3,d4.w) 341 | addq #1,d7 342 | cmp.w d3,d7 343 | bcs.s .dynamic_loop1 344 | 345 | .dynamic_loop2: 346 | move.b (a4,d7.w),d4 347 | clr.w (a3,d4.w) 348 | addq #1,d7 349 | cmp.w #19,d7 350 | bcs.s .dynamic_loop2 351 | 352 | ; build huffman table for code lengths (use lencode temporarily) 353 | movem.l a0-a1,-(sp) 354 | lea lencode,a0 355 | move.l a3,a1 356 | moveq #19,d0 357 | bsr construct 358 | movem.l (sp)+,a0-a1 359 | tst.w d0 360 | beq.s .lengths_ok 361 | moveq #-4,d0 ; require complete code set here 362 | bra.w .dynamic_done 363 | 364 | .lengths_ok: 365 | ; read length/literal and distance code length tables 366 | moveq #0,d7 ; index 367 | .dynamic_loop3: 368 | move.w d1,d4 369 | add.w d2,d4 370 | cmp.w d4,d7 371 | bge.w .dynamic_next 372 | 373 | bsr decode 374 | cmp.w #16,d0 375 | bcs.s .length_15 376 | 377 | moveq #0,d4 ; len 378 | cmp.w #16,d0 379 | bne.s .length_not_16 380 | tst.w d7 381 | bne.s .index_ok 382 | moveq #-5,d0 ; no last length! 383 | bra.w .dynamic_done 384 | .index_ok: 385 | move.w d7,d5 386 | subq #1,d5 387 | add.w d5,d5 388 | move.w (a3,d5.w),d4 ; last length 389 | 390 | moveq #2,d0 391 | bsr bits 392 | addq #3,d0 393 | bra.s .symbol_ok 394 | 395 | .length_not_16: 396 | cmp.w #17,d0 ; repeat zero 3..10 times 397 | bne.s .length_not_17 398 | moveq #3,d0 399 | bsr bits 400 | addq #3,d0 401 | bra.s .symbol_ok 402 | 403 | .length_not_17: 404 | moveq #7,d0 ; == 18, repeat zero 11..138 times 405 | bsr bits 406 | add.w #11,d0 407 | 408 | .symbol_ok: 409 | move.w d1,d5 410 | add.w d2,d5 411 | move.w d7,d6 412 | add.w d0,d6 413 | cmp.w d5,d6 414 | bls.s .length_ok 415 | moveq #-6,d0 ; too many lengths! 416 | bra.w .dynamic_done 417 | 418 | .length_ok: 419 | subq #1,d0 420 | bmi.s .dynamic_loop3 421 | .repeat: 422 | move.w d7,d5 ; repeat last or zero symbol times 423 | add.w d5,d5 424 | move.w d4,(a3,d5.w) 425 | addq #1,d7 426 | dbra d0,.repeat 427 | bra.s .dynamic_loop3 428 | 429 | .length_15: 430 | move.w d7,d4 ; length in 0..15 431 | add.w d4,d4 432 | move.w d0,(a3,d4.w) 433 | addq #1,d7 434 | bra.w .dynamic_loop3 435 | 436 | ; check for end-of-block code -- there better be one! 437 | .dynamic_next: 438 | tst.w 256*2(a3) 439 | bne.s .end_of_block 440 | moveq #-9,d0 441 | bra.w .dynamic_done 442 | 443 | .end_of_block: 444 | ; build huffman table for literal/length codes 445 | movem.l a0-a1,-(sp) 446 | lea lencode,a0 447 | move.l a3,a1 448 | move.w d1,d0 449 | bsr construct 450 | movem.l (sp)+,a0-a1 451 | 452 | tst.w d0 453 | bmi.s .bad_length_codes 454 | beq.s .length_done 455 | move.l lencode+huffman_count,a4 456 | move.l d1,d5 457 | sub.l (a4),d5 458 | cmp.w #1,d5 459 | beq.s .length_done 460 | .bad_length_codes: 461 | moveq #-7,d0 462 | bra.s .dynamic_done 463 | 464 | .length_done: 465 | ; build huffman table for distance codes 466 | movem.l a0-a1,-(sp) 467 | lea distcode,a0 468 | move.l a3,a1 469 | add.w d1,a1 470 | add.w d1,a1 471 | move.w d2,d0 472 | bsr construct 473 | movem.l (sp)+,a0-a1 474 | 475 | tst.w d0 476 | bmi.s .bad_distance_codes 477 | beq.s .distance_done 478 | move.l distcode+huffman_count,a4 479 | move.l d2,d5 480 | sub.l (a4),d5 481 | cmp.w #1,d5 482 | beq.s .distance_done 483 | .bad_distance_codes: 484 | moveq #-8,d0 485 | bra.s .dynamic_done 486 | 487 | .distance_done: 488 | lea lencode,a2 489 | lea distcode,a3 490 | bsr codes 491 | 492 | .dynamic_done: 493 | movem.l (sp)+,d1-d7/a2-a4 494 | rts 495 | 496 | ; In: a0 = input buffer 497 | ; In: a1 = output buffer 498 | ; In: a2 = lencode 499 | ; In: a3 = distcode 500 | ; Out: d0 = error code 501 | codes: movem.l d1-d2/a4-a5,-(sp) 502 | lea codes_tables,a4 503 | 504 | ; decode literals and length/distance pairs 505 | .codes_loop: 506 | bsr decode 507 | tst.w d0 508 | bmi .codes_done ; invalid symbol 509 | cmp.w #256,d0 510 | beq.s .codes_done 511 | bhi.s .huff 512 | move.b d0,(a1)+ ; literal: symbol is the byte 513 | bra.s .codes_loop 514 | .huff: sub.w #257,d0 ; get and compute length 515 | cmp.w #29,d0 516 | bcs.s .codes_ok 517 | moveq #-10,d0 ; invalid fixed code 518 | bra.s .codes_done 519 | 520 | .codes_ok: 521 | add.w d0,d0 522 | move.w codes_lens(a4,d0.w),d1 523 | move.w codes_lext(a4,d0.w),d0 524 | bsr bits 525 | add.w d0,d1 526 | 527 | ; get and check distance 528 | move.l a2,a5 529 | move.l a3,a2 530 | bsr decode 531 | move.l a5,a2 532 | tst.w d0 533 | bmi .codes_done ; invalid symbol 534 | 535 | add.w d0,d0 536 | move.w codes_dists(a4,d0.w),d2 537 | add.w #codes_dext,d0 538 | move.w (a4,d0.w),d0 539 | bsr bits 540 | add.w d0,d2 541 | 542 | ; copy length bytes from distance bytes back 543 | move.l a1,a5 544 | sub.l output,a5 545 | neg.w d2 546 | move.w d1,d7 547 | subq #1,d7 548 | bmi.s .codes_loop 549 | .copy: move.b (a1,d2.w),(a1)+ 550 | dbra d7,.copy 551 | bra .codes_loop 552 | 553 | .codes_done: 554 | movem.l (sp)+,d1-d2/a4-a5 555 | rts 556 | 557 | ; In: a0 = huffman 558 | ; In: a1 = length 559 | ; In: d0 = n 560 | ; Out: d0 = left 561 | construct: 562 | movem.l d1-d3/d7/a2-a4,-(sp) 563 | moveq #0,d2 564 | 565 | ; count number of codes of each length 566 | move.l huffman_count(a0),a2 567 | moveq #MAXBITS,d7 568 | .construct_loop1: 569 | clr.w (a2)+ 570 | dbra d7,.construct_loop1 571 | 572 | ; assumes lengths are within bounds 573 | move.l huffman_count(a0),a2 574 | moveq #0,d7 575 | .construct_loop2: 576 | move.w d7,d1 577 | add.w d1,d1 578 | move.w (a1,d1.w),d1 579 | add.w d1,d1 580 | add.w #1,(a2,d1.w) 581 | addq #1,d7 582 | cmp.w d0,d7 583 | bcs.s .construct_loop2 584 | 585 | cmp.w (a2),d0 ; no codes! 586 | beq.s .construct_done ; complete, but decode will fail 587 | 588 | ; check for an over-subscribed or incomplete set of lengths 589 | moveq #1,d2 ; one possible code of zero length 590 | moveq #2,d7 591 | .construct_loop3: 592 | add.w d2,d2 ; one mor bit, double codes left 593 | sub.w (a2,d7.w),d2 ; deduct count from possible codes 594 | bmi .construct_done ; over-subscribed--return negative 595 | addq #2,d7 ; left > 0 means incomplete 596 | cmp.w #MAXBITS*2,d7 597 | ble .construct_loop3 598 | 599 | ; generate offsets into symbol table for each length for sorting 600 | lea offs,a3 601 | clr.w 2(a3) 602 | moveq #2,d7 603 | .construct_loop4: 604 | move.w (a3,d7.w),d3 605 | add.w (a2,d7.w),d3 606 | move.w d3,2(a3,d7.w) 607 | addq #2,d7 608 | cmp.w #MAXBITS*2,d7 609 | bcs.s .construct_loop4 610 | 611 | ; put symbols in table sorted by length, by symbol order within each length 612 | move.l huffman_symbol(a0),a2 613 | moveq #0,d7 614 | .construct_loop5: 615 | move.w d7,d3 616 | add.w d3,d3 617 | move.w (a1,d3.w),d3 618 | beq.s .zero 619 | add.w d3,d3 620 | move.w (a3,d3.w),d1 621 | add.w d1,d1 622 | move.w d7,(a2,d1.w) 623 | add.w #1,(a3,d3.w) 624 | .zero: addq #1,d7 625 | cmp.w d0,d7 626 | bcs.s .construct_loop5 627 | 628 | .construct_done: ; return zero for complete set, positive for incomplete set 629 | move.w d2,d0 630 | movem.l (sp)+,d1-d3/d7/a2-a4 631 | rts 632 | 633 | ; In: a0 = input buffer 634 | ; In: a2 = huffman 635 | ; Out: d0 = symbol 636 | decode: movem.l d1-d7/a3,-(sp) 637 | move.l bitbuf,d0 ; bitbuf 638 | move.l bitcnt,d7 ; left 639 | moveq #0,d1 ; code 640 | moveq #0,d2 ; first 641 | moveq #0,d3 ; count 642 | moveq #0,d4 ; index 643 | moveq #1,d5 ; len 644 | move.l huffman_count(a2),a3 ; next 645 | addq #2,a3 646 | subq #1,d7 647 | bmi.s .decode_none_left 648 | .decode_loop: 649 | move.l d0,d6 650 | and.l #1,d6 651 | or.l d6,d1 652 | lsr.l #1,d0 653 | move.w (a3)+,d3 654 | move.w d1,d6 655 | sub.w d3,d6 656 | cmp.w d2,d6 657 | bge.s .update 658 | move.l d0,bitbuf 659 | sub.l d5,bitcnt 660 | and.l #7,bitcnt 661 | 662 | sub.w d2,d1 663 | add.w d4,d1 664 | add.w d1,d1 665 | move.l huffman_symbol(a2),a3 666 | move.w (a3,d1.w),d0 667 | bra.s .decode_done 668 | 669 | .update: 670 | add.w d3,d4 671 | add.w d3,d2 672 | add.w d2,d2 673 | add.w d1,d1 674 | addq #1,d5 675 | dbra d7,.decode_loop 676 | 677 | .decode_none_left: 678 | move.w #MAXBITS+1,d7 679 | sub.w d5,d7 680 | bne.s .ok1 681 | moveq #-10,d0 682 | bra.s .decode_done 683 | .ok1: move.b (a0)+,d0 684 | cmp.w #8,d7 685 | bls.s .ok2 686 | moveq #8,d7 687 | .ok2: subq #1,d7 688 | bra.s .decode_loop 689 | 690 | .decode_done: 691 | movem.l (sp)+,d1-d7/a3 692 | rts 693 | 694 | section __MERGED,data 695 | 696 | codes_tables: ; Size base for length codes 257..285 697 | dc.w 3 698 | dc.w 4 699 | dc.w 5 700 | dc.w 6 701 | dc.w 7 702 | dc.w 8 703 | dc.w 9 704 | dc.w 10 705 | dc.w 11 706 | dc.w 13 707 | dc.w 15 708 | dc.w 17 709 | dc.w 19 710 | dc.w 23 711 | dc.w 27 712 | dc.w 31 713 | dc.w 35 714 | dc.w 43 715 | dc.w 51 716 | dc.w 59 717 | dc.w 67 718 | dc.w 83 719 | dc.w 99 720 | dc.w 115 721 | dc.w 131 722 | dc.w 163 723 | dc.w 195 724 | dc.w 227 725 | dc.w 258 726 | ; Extra bits for length codes 257..285 727 | dc.w 0 728 | dc.w 0 729 | dc.w 0 730 | dc.w 0 731 | dc.w 0 732 | dc.w 0 733 | dc.w 0 734 | dc.w 0 735 | dc.w 1 736 | dc.w 1 737 | dc.w 1 738 | dc.w 1 739 | dc.w 2 740 | dc.w 2 741 | dc.w 2 742 | dc.w 2 743 | dc.w 3 744 | dc.w 3 745 | dc.w 3 746 | dc.w 3 747 | dc.w 4 748 | dc.w 4 749 | dc.w 4 750 | dc.w 4 751 | dc.w 5 752 | dc.w 5 753 | dc.w 5 754 | dc.w 5 755 | dc.w 0 756 | ; Offset base for distance codes 0..29 757 | dc.w 1 758 | dc.w 2 759 | dc.w 3 760 | dc.w 4 761 | dc.w 5 762 | dc.w 7 763 | dc.w 9 764 | dc.w 13 765 | dc.w 17 766 | dc.w 25 767 | dc.w 33 768 | dc.w 49 769 | dc.w 65 770 | dc.w 97 771 | dc.w 129 772 | dc.w 193 773 | dc.w 257 774 | dc.w 385 775 | dc.w 513 776 | dc.w 769 777 | dc.w 1025 778 | dc.w 1537 779 | dc.w 2049 780 | dc.w 3073 781 | dc.w 4097 782 | dc.w 6145 783 | dc.w 8193 784 | dc.w 12289 785 | dc.w 16385 786 | dc.w 24577 787 | ; Extra bits for distance codes 0..29 788 | dc.w 0 789 | dc.w 0 790 | dc.w 0 791 | dc.w 0 792 | dc.w 1 793 | dc.w 1 794 | dc.w 2 795 | dc.w 2 796 | dc.w 3 797 | dc.w 3 798 | dc.w 4 799 | dc.w 4 800 | dc.w 5 801 | dc.w 5 802 | dc.w 6 803 | dc.w 6 804 | dc.w 7 805 | dc.w 7 806 | dc.w 8 807 | dc.w 8 808 | dc.w 9 809 | dc.w 9 810 | dc.w 10 811 | dc.w 10 812 | dc.w 11 813 | dc.w 11 814 | dc.w 12 815 | dc.w 12 816 | dc.w 13 817 | dc.w 13 818 | ; permutation of code length codes 819 | order: dc.b 16*2 820 | dc.b 17*2 821 | dc.b 18*2 822 | dc.b 0*2 823 | dc.b 8*2 824 | dc.b 7*2 825 | dc.b 9*2 826 | dc.b 6*2 827 | dc.b 10*2 828 | dc.b 5*2 829 | dc.b 11*2 830 | dc.b 4*2 831 | dc.b 12*2 832 | dc.b 3*2 833 | dc.b 13*2 834 | dc.b 2*2 835 | dc.b 14*2 836 | dc.b 1*2 837 | dc.b 15*2 838 | virgin: dc.b 1 839 | 840 | section __MERGED,bss 841 | 842 | output: ds.l 1 843 | bitbuf: ds.l 1 844 | bitcnt: ds.l 1 845 | lencode: ds.l 2 846 | distcode: ds.l 2 847 | codes_data: ds.b 1328 848 | offs: ds.w MAXBITS+1 849 | 850 | end 851 | --------------------------------------------------------------------------------