Add files via upload

This commit is contained in:
Antoine Vignau 2020-06-08 22:56:32 +02:00 committed by GitHub
parent 937479d95d
commit 26c8981329
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 4512 additions and 0 deletions

14
source/twilight/rings/M.S Normal file
View File

@ -0,0 +1,14 @@
nol ;turn listing off (NO List)
ovr ;always assemble
asm rings ;assemble the file
lnk rings.l
lnk 5/misc
lib 5
typ EXE
sav rings.d ;useful for testing!
* typ $BC
* cmd auxtype impulse,$4004

View File

@ -0,0 +1,550 @@
_BLOCKMOVE MAC
Tool $2B02
<<<
^DISPOSEALL MAC
PHW ]1
Tool $1102
<<<
PEIL MAC
PEI ]1+2
PEI ]1
<<<
QUIT_GS MAC
GSOS $2029;]1
<<<
_STARTCYCLETIMING mac
pea 0
pea 0
pea 0
jsl StartCycleTiming
eom
_CALCCYCLETIME mac
pea #^]1
pea #]1
jsl CalcCycleTime
eom
_STARTREALTIMING mac
pea 0
pea 0
pea 0
jsl StartRealTiming
eom
_CALCREALTIME mac
pea #^]1
pea #]1
jsl CalcRealTime
eom
^BLOCKMOVE MAC
PxL ]1;]2;]3
Tool $2B02
<<<
PXL MAC
DO ]0/1
PHL ]1
DO ]0/2
PHL ]2
DO ]0/3
PHL ]3
DO ]0/4
PHL ]4
FIN
FIN
FIN
FIN
<<<
BNEL MAC
BEQ OV
BRL ]1
OV <<<
^HEXIT MAC
P2SW ]1
Tool $2A0B
<<<
P2SW MAC
PHA
PHA
IF #=]1
PEA ]1
ELSE
IF MX/2
LDA ]1+1
PHA
FIN
LDA ]1
PHA
FIN
<<<
printhex MAC ;format: printhex 'value:';value
~HexIt ]2
pll Hascii
printblock #HText
bra x
HText asc ]1
HAscii asc '0000',00
x <<<
_INT2DEC MAC
Tool $260B
<<<
_STARTTIMING mac
pea 0
pea 0
pea 0
jsl StartTiming
eom
_CALCTIME mac
pea #^]1
pea #]1
jsl CalcTime
eom
_DISPOSEHANDLE MAC
Tool $1002
<<<
_TOTALMEM MAC
Tool $1D02
<<<
CLOSE_GS MAC
GSOS $2014;]1
<<<
OPEN_GS MAC
GSOS $2010;]1
<<<
READ_GS MAC
GSOS $2012;]1
<<<
GSOS MAC
jsl $E100A8
da ]1
adrl ]2
<<<
_READTIMEHEX MAC
Tool $D03
<<<
_TICKCOUNT MAC
Tool $1006
<<<
_DISPOSEALL MAC
Tool $1102
<<<
_SETHANDLESIZE MAC
Tool $1902
<<<
_FINDHANDLE MAC
Tool $1A02
<<<
_HLOCK MAC
Tool $2002
<<<
BCCL MAC
BCS OV
BRL ]1
OV <<<
BLTL MAC
BGE OV
BRL ]1
OV <<<
SUB MAC
IF #=]2
IF #=]1
ERR 1
FIN
FIN
SEC
LDA ]1
SBC ]2
DO ]0/3
STA ]3
ELSE
IF #=]2
STA ]1
ELSE
STA ]2
FIN
FIN
IF MX>1
LDHI ]1
IF #=]2
SBC ]2/$100
ELSE
SBC ]2+1
FIN
DO ]0/3
STA ]3+1
ELSE
IF #=]2
STA ]1+1
ELSE
STA ]2+1
FIN
FIN
FIN
<<<
LDHI MAC
IF #=]1
LDA ]1/$100
ELSE
LDA ]1+1
FIN
<<<
^DISPOSEHANDLE MAC
PHL ]1
Tool $1002
<<<
_UNPACKBYTES MAC
Tool $2703
<<<
_HEXIT MAC
Tool $2A0B
<<<
_TEXTSTARTUP MAC
Tool $20C
<<<
_TEXTSHUTDOWN MAC
Tool $30C
<<<
^WRITECSTRING MAC
PHL ]1
Tool $200C
<<<
ADD MAC
IF #=]2
IF #=]1
ERR 1
FIN
FIN
CLC
LDA ]1
ADC ]2
DO ]0/3
STA ]3
ELSE
IF #=]2
STA ]1
ELSE
STA ]2
FIN
FIN
IF MX>1
LDA ]1+1
IF #=]2
ADC ]2/$100
ELSE
ADC ]2+1
FIN
DO ]0/3
STA ]3+1
ELSE
IF #=]2
STA ]1+1
ELSE
STA ]2+1
FIN
FIN
FIN
<<<
BCSL MAC
BCC OV
BRL ]1
OV <<<
ADD4 MAC
CLC
DO ]0/3
IF #=]1
LDA #<]1
ELSE
LDA ]1
FIN
IF #=]2
ADC #<]2
ELSE
ADC ]2
FIN
STA ]3
IF #=]1
LDA #^]1
ELSE
LDA ]1+2
FIN
IF #=]2
ADC #^]2
ELSE
ADC ]2+2
FIN
STA ]3+2
ELSE
IF #=]1
ADC #<]1
ELSE
ADC ]1
FIN
STA ]2
IF #=]1
LDA #^]1
ELSE
LDA ]1+2
FIN
ADC #0
STA ]2+2
FIN
<<<
SUB4 MAC
SEC
DO ]0/3
IF #=]1
LDA #<]1
ELSE
LDA ]1
FIN
IF #=]2
SBC #<]2
ELSE
SBC ]2
FIN
STA ]3
IF #=]1
LDA #^]1
ELSE
LDA ]1+2
FIN
IF #=]2
SBC #^]2
ELSE
SBC ]2+2
FIN
STA ]3+2
ELSE
IF #=]1
SBC #<]1
ELSE
SBC ]1
FIN
STA ]2
IF #=]1
LDA #^]1
ELSE
LDA ]1+2
FIN
SBC #0
STA ]2+2
FIN
<<<
_OPEN MAC
DOS16 $10;]1
<<<
_NEWLINE MAC
DOS16 $11;]1
<<<
_READ MAC
DOS16 $12;]1
<<<
_CLOSE MAC
DOS16 $14;]1
<<<
_GET_EOF MAC
DOS16 $19;]1
<<<
^NEWHANDLE MAC
P2SL ]1
PxW ]2;]3
PHL ]4
Tool $902
<<<
PXW MAC
DO ]0/1
PHW ]1
DO ]0/2
PHW ]2
DO ]0/3
PHW ]3
DO ]0/4
PHW ]4
FIN
FIN
FIN
FIN
<<<
P2SL MAC
PHA
PHA
IF #=]1
PEA ^]1
ELSE
PHW ]1+2
FIN
PHW ]1
<<<
BGT MAC
BEQ OV
BGE ]1
OV <<<
^MTSTARTUP MAC
Tool $203
<<<
^MTSHUTDOWN MAC
Tool $303
<<<
^MMSTARTUP MAC
PHA
Tool $202
<<<
^MMSHUTDOWN MAC
PHW ]1
Tool $302
<<<
_QUIT MAC
DOS16 $29;]1
<<<
DOS16 MAC
JSL $E100A8
DA ]1
ADRL ]2
<<<
TOOL MAC
LDX #]1
JSL $E10000
<<<
**************************************************
key MAC
ldal $E0C000
bmi x
brl ]1
x
stal $E0C010
<<<
check MAC check string exactly
mvl #Input_Buffer;String_Source
mvl ]1;String_Object
jsr Check_String
bcsl ]2 if not, then goto ]2
<<<
find MAC find string occurance
mvl #Input_Buffer;String_Source
mvl ]1;String_Object
jsr Find_String
bcsl ]2 if not, then goto ]2
<<<
request MAC
printxy ]1;]2;]3
mvl #Input_Buffer;String_Source
jsr get_String
<<<
printxy MAC
mvw ]1;XLoc
mvw ]2;YLoc
mvl #s;String_Source
jsr Draw_Text
bra x
s asc ]3,00
x <<<
print MAC
mvl #s;String_Source
jsr Draw_Text
bra x
s asc ]1,00
x <<<
printblockxy MAC draw shr text characters
mvw ]1;XLoc
mvw ]2;YLoc
mvl ]3;string_source
jsr Draw_Text
<<<
printblock MAC draw shr text characters
mvl ]1;string_source
jsr Draw_Text
<<<
phw MAC push word
if #=]1
pea ]1
else
if MX/2
lda ]1+1
pha
fin
lda ]1
pha
fin
<<<
plw MAC pull word
pla
sta ]1
<<<
mvw MAC move word
lda ]1
DO ]0/2
STA ]2
DO ]0/3
STA ]3
DO ]0/4
STA ]4
FIN
FIN
FIN
<<<
mvl MAC move long
lda ]1
do ]0/2
sta ]2
do ]0/3
sta ]3
do ]0/4
sta ]4
fin
fin
fin
if #=]1
lda ^]1
else
lda ]1+2
fin
do ]0/2
sta ]2+2
do ]0/3
sta ]3+2
do ]0/4
sta ]4+2
fin
fin
fin
<<<
phl MAC push long
if #=]1
pea ^]1
else
phw ]1+2
fin
phw ]1
<<<
PLL MAC
PLA
DO ]0/1
STA ]1
DO ]0/2
STA ]2
DO ]0/3
STA ]3
DO ]0/4
STA ]4
FIN
FIN
FIN
FIN
PLA
DO ]0/1
STA ]1+2
DO ]0/2
STA ]2+2
DO ]0/3
STA ]3+2
DO ]0/4
STA ]4+2
FIN
FIN
FIN
FIN
<<<
BEQL MAC
BNE OV
BRL ]1
OV <<<
_MMSHUTDOWN MAC
Tool $302
<<<

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,14 @@
# static makefile
# by Jim Maricondo
# v1.0 - 5/23/93 12:39pm - coded.
rings.r: rings.rez 22/t2common.rez
compile rings.rez keep=rings.r
rings: rings.r rings.d
duplicate -d rings.d rings
duplicate -r rings.r rings
setfile -at $4004 -t $bc rings -m .
cp rings *:system:cdevs:twilight:rings
22:beep

View File

@ -0,0 +1,87 @@
#include "types.rez"
#include "22:t2common.rez"
resource rT2ModuleFlags (moduleFlags) {
fGrafPort320+
fLeavesUsableScreen+
fFadeIn+
fFadeOut, // module flags word
$01, // enabled flag (unimplemented)
$0110, // minimum T2 version required
NIL, // reserved
"Rings" // module name
};
// --- Version resource
resource rVersion (moduleVersion) {
{1,0,0,alpha,2}, // Version
verUS, // US Version
"T2 Rings Module", // program's name
"By Chris McKinsey & JRM.\n" // copyright notice
"Copyright 1993-4 DigiSoft Innovations."
};
// --- About icon resource
resource rIcon (moduleIcon) {
$8000, // kind
$0014, // height
$0016, // width
$"F00000000000000000000F"
$"0FFFFFFFFFFFFFFFFFFFF0"
$"0F000000000000000000F0"
$"0F030F0F3F0F0F330F00F0"
$"0F00F00F00303003F330F0"
$"0F0F03F033303F3030F0F0"
$"0F0300030F00F0303300F0"
$"0F0030F303330F303F30F0"
$"0F0F3F03F00F0303F0F0F0"
$"0F0300F00003F3030300F0"
$"0F00F330FF033F0FF030F0"
$"0F000000000000000000F0"
$"0FFFFFFFFFFFFFFFFAFFF0"
$"0000000000000000000000"
$"F0FFFFFFFFFFFFFFFFFF0F"
$"F0FFFFFFFFFFFFFFFFFF0F"
$"F0FF4AFFFFFFFFFFFFFF0F"
$"F0CCCCCCCCCCCCCCCCCC0F"
$"F0FFFFFFFFFFFFFFFAFF0F"
$"F00000000000000000000F",
$"0FFFFFFFFFFFFFFFFFFFF0"
$"FFFFFFFFFFFFFFFFFFFFFF"
$"FFFFFFFFFFFFFFFFFFFFFF"
$"FFFFFFFFFFFFFFFFFFFFFF"
$"FFFFFFFFFFFFFFFFFFFFFF"
$"FFFFFFFFFFFFFFFFFFFFFF"
$"FFFFFFFFFFFFFFFFFFFFFF"
$"FFFFFFFFFFFFFFFFFFFFFF"
$"FFFFFFFFFFFFFFFFFFFFFF"
$"FFFFFFFFFFFFFFFFFFFFFF"
$"FFFFFFFFFFFFFFFFFFFFFF"
$"FFFFFFFFFFFFFFFFFFFFFF"
$"FFFFFFFFFFFFFFFFFFFFFF"
$"FFFFFFFFFFFFFFFFFFFFFF"
$"0FFFFFFFFFFFFFFFFFFFF0"
$"0FFFFFFFFFFFFFFFFFFFF0"
$"0FFFFFFFFFFFFFFFFFFFF0"
$"0FFFFFFFFFFFFFFFFFFFF0"
$"0FFFFFFFFFFFFFFFFFFFF0"
$"0FFFFFFFFFFFFFFFFFFFF0";
};
// --- rTextForLETextBox2 Templates
resource rTextForLETextBox2 (moduleMessage) {
TBFont TBShaston "\$00\$08"
TBLeftJust
TBBackColor TBColorF
TBForeColor TBColor1
TBStyleBold "Rings"
TBForeColor TBColor0
TBStylePlain
" is cool!"
};

View File

@ -0,0 +1,515 @@
**************************************************
* Rings Demo *
* By Christopher Martin McKinsey *
* Started: December 20, 1991 *
**************************************************
cas in
mx %00
rel
use macros
ext MultAX,ShadowOn,ShadowOff,MakeMask,getmem,deref
ext showcell,loadcells,loadcellspal,readbeam,error
ext gosubHand,erasebob
put t2common.equ
Height = $08
Width = Height+4
YLoc = Width+4
XLoc = YLoc+2
YVel = XLoc+2
XVel = YVel+2
Mask = XVel+2
Image = Mask+4
ImgNum = Image+4
Work_Ptr = ImgNum+2
cellRefPtr = Work_Ptr+4
MovePtr = $80
rowBytes = 160
pixsHigh = 200
Left_Arrow = $08
Right_Arrow = $15
not = 0
*-------------------------------------------------
dum 1
* dp da 0
Bank db 0 ;This is how the stack is set up
rtlAddr adr 0 ;with DP at the top and Result
T2data2 adrl 0 ;occupying the top four bytes
T2data1 adrl 0
T2Message da 0
T2Result adrl 0
T2StackSize adrl 0
dend
*-------------------------------------------------
Rings_T2 = *
phb
phk
plb
tdc
sta OurDP
do not
brk 00
fin
sep #$30
ldal $E1C035
rep #$30
bit #$08
bne bad
lda T2Message,s
cmp #BlankT2
beq doBlank
do 0
cmp #MakeT2
beql doMake
cmp #HitT2
beql doHit
* cmp #KillT2
* beql doKill
cmp #SaveT2
beql doSave
cmp #LoadSetupT2
beql doLoadSetup
* cmp #UnloadSetupT2
* beql doUnloadSetup
fin
bad brl Bye
*-------------------------------------------------
doBlank = *
LDX #$FE ; init our DP
]lp STZ $00,X
DEX
DEX
BPL ]lp
lda T2data1,s
sta MovePtr ;save this in our own DP
lda T2data1+2,s
sta MovePtr+2
~MMStartUp
pla
ora #$0100
sta MyID
sta My_ID
pea 0
pea 0
pea 0
pea #160
pea #200
jsl shadowon
jsl eraseBob
jsl shadowoff
do 0
ldx #768+32-2
lda #$00
]l stal $E19D00,x
dex
dex
bpl ]l
fin
*
* load in the cells
*
phl #cells
jsl loadcells
bcsl return
stx cellRefPtr
sty cellRefPtr+2
lda [cellRefPtr]
sta numFrames
txa
clc
adc #$02
sta cellRefPtr
tya
adc #$00
sta cellRefPtr+2
ldx #$20-2
]l lda loadcellspal,x
stal $E19E00,x
dex
dex
bpl ]l
jsr init
do not
brk 01
fin
]l
jsr Animate
lda [MovePtr]
beq ]l
jsl shadowon
do 0
ldal $e0c000
bpl ]l
stal $e0c010
and #$007f
cmp #Right_Arrow
bne :1
lda numactors
cmp #10
beq ]l
inc numactors
bra ]l
:1 cmp #Left_Arrow
bne :2
lda numactors
cmp #$01
beq ]l
dec numactors
bra ]l
:2
fin
return
~DisposeAll MyID
do 0
lda MyID
and #$F0FF
pha
_MMShutDown
fin
Bye = *
skip = *
plb
lda 1,s ; move up RTL address
sta 1+10,s
lda 2,s
sta 2+10,s
tsc ; Remove input parameters.
clc
adc #10
tcs
clc
rtl
**************************************************
* This is a GLOBAL data area for the program *
**************************************************
errorMsg str 'Error loading Rings Demo.'
My_ID ent
ds 2
oldSP ds 2
backcolor ds 2
cells strl '*:system:cdevs:twilight:Cells'
frame dw 0
numFrames dw 0
MaxActors = 10 ; 20
cellxvel ds 2*MaxActors
cellyvel ds 2*MaxActors
cellxloc ds 2*MaxActors
cellyloc ds 2*MaxActors
NumActors dw MaxActors
origxvel dw +1,+2,+3,+4,+5,+6,+7,+8,+9,+10
origyvel dw +5,+4,+3,+2,+1,+5,+4,+3,+2,+1
*=================================================
MyID ds 2
OurDP ds 2
*=================================================
**************************************************
* Routine to test multiple animations *
**************************************************
Animate
jsr Move
jsr Draw
jsl shadowon
jsr Show
jsl shadowoff
jsr Erase
inc frame
lda frame
cmp numFrames
bne :X
stz frame
:X rts
**************************************************
* *
**************************************************
Move
lda numActors
sta :lup
ldx #$00
]l
lda frame
asl
asl
asl
tay
lda #rowBytes
sec
sbc [cellRefPtr],y ;frame byte width
asl
sta 0
lda cellxloc,x
clc
adc cellxvel,x
cmp 0
blt :Do_Y
lda #$00
sec
sbc cellxvel,x
sta cellxvel,x
clc
adc cellxloc,x
:Do_Y
sta cellxloc,x
iny
iny
lda #pixsHigh
sec
sbc [cellRefPtr],y ;frame height
sta 0
lda cellyloc,x
clc
adc cellyvel,x
cmp 0
blt :Do_Next
lda #$00
sec
sbc cellyvel,x
sta cellyvel,x
clc
adc cellyloc,x
:Do_Next
sta cellyloc,x
inx
inx
dec :lup
bne ]l
rts
:lup dw 0
**************************************************
* Draw the shape *
**************************************************
Draw
stz ImgNum
]l
lda frame
asl
asl
asl
clc
adc #$04
tay
lda [cellRefPtr],y
pha
iny
iny
lda [cellRefPtr],y
pha
lda ImgNum
asl
tax
lda cellyloc-1,x
lsr
lsr
adc cellyloc-1,x
adc cellxloc,x
lsr
clc
adc #$2000
ply
plx
jsl gosubHand
inc ImgNum
lda ImgNum
cmp NumActors
blt ]l
rts
**************************************************
* Show the shapes to the screen *
**************************************************
Show
stz imgnum
]l
lda imgnum
asl
tax
mvw cellxloc,x;xloc
mvw cellyloc,x;yloc
mvw cellxvel,x;xvel
mvw cellyvel,x;yvel
lda frame
asl
asl
asl
tay
lda [cellRefPtr],y
sta width
iny
iny
lda [cellRefPtr],y
sta height
jsr Show_Image
inc imgnum
lda imgnum
cmp NumActors
blt ]l
rts
**************************************************
* Erase the shapes *
**************************************************
Erase
stz ImgNum
]l
lda backcolor
pha
lda ImgNum
asl
tax
lda cellxloc,x
pha
lda cellyloc,x
pha
lda frame
asl
asl
asl
tay
lda [cellRefPtr],y
pha
iny
iny
lda [cellRefPtr],y
pha
jsl eraseBob
inc ImgNum
lda ImgNum
cmp NumActors
blt ]l
rts
**************************************************
* init x and y locs, plus vels *
**************************************************
init
stz frame
lda #160
sec
sbc [cellRefPtr]
sta 0
ldy #$02
lda [cellRefPtr],y
lsr
sta 2
lda #100
sec
sbc 2
sta 2
ldx #$00
ldy NumActors
]l lda origxvel,x
sta cellxvel,x
lda origyvel,x
sta cellyvel,x
lda 0
sta cellxloc,x
lda 2
sta cellyloc,x
inx
inx
dey
bne ]l
rts
**************************************************
* Show the image here *
**************************************************
Show_Image ent
ldx Xvel
txa
lsr
bcc :Even
txa
bmi :neg
inx
bra :Even
:neg dex
:Even stx XVel
lda XVel
beq :Check_Y
bpl :Right
:Left sub Width;XVel;Width
bra :Check_Y
:Right lda Xloc
sec
sbc XVel
cmp #320
blt :rok
lda #0
:rok sta Xloc
add XVel;Width
:Check_Y
lda YVel
beq :Show_It
bpl :Down
:Up sub Height;YVel;Height
bra :Show_It
:Down lda YLoc
sec
sbc YVel
cmp #200
blt :dok
lda #0
:dok sta Yloc
add YVel;Height
:Show_It
pei xloc
pei yloc
pei width
pei height
jsl showcell
rts
**************************************************
sav Rings.l

View File

@ -0,0 +1,88 @@
* T2 Common Module Equates. By Jim Maricondo.
* v1.0 - 05/24/92 - Initial Version.
* v1.1 - 05/29/92 - Revised 'cuz of new t2common.rez. - v1.0d33
* v1.2 - 10/24/92 - IPC equates added - v1.0.1b1. - datafield added
* v1.3 - 12/13/92 - mfOverrideSound added - v1.0.1b2
* Resources types.
rT2ModuleFlags equ $1000
rT2ExtSetup1 equ $1001
rT2ModuleWord equ $1002 ; reztype for module words in T2 setup
* Action message codes sent to modules.
MakeT2 equ 0 ; Make module-specific ctls.
SaveT2 equ 1 ; Save new preferences
BlankT2 equ 2 ; Blank the screen.
LoadSetupT2 equ 3 ; Load any resources from yo' fork
UnloadSetupT2 equ 4 ; Dispose of any resources from yo' fk.
KillT2 equ 5 ; Module setup being closed.
HitT2 equ 6 ; Setup window control hit.
do 0
* How the stack is setup when a module gets called.
dp equ 1 ; This is how the stack is set up
Bank equ dp+2 ; with DP at the top and Result
rtlAddr equ Bank+1 ; occuping the top 4 bytes
T2data2 equ rtlAddr+3
T2data1 equ T2data2+4
T2Message equ T2data1+4
T2Result equ T2Message+2
T2StackSize equ T2Result+4
* Softswitches
KBD equ >$E0C000
KBDSTRB equ >$E0C010
RDVBLBAR equ >$E0C019 ; bit 7 = 1 if not VBL
TBCOLOR equ >$E0C022
NEWVIDEO equ >$E0C029
VERTCNT equ >$E0C02E
SPKR equ >$E0C030
CLOCKCTL equ >$E0C034 ; border color / rtc register
SHADOW equ >$E0C035
INCBUSYFLG equ >$E10064 ; increment busy flag
DECBUSYFLG equ >$E10068 ; decrement busy flag
SHR equ >$E12000
SCBS equ >$E19D00
PALETTES equ >$E19E00
fin
* Boolean logic
FALSE equ 0
TRUE equ 1
* T2 External IPC
t2TurnOn equ $9000
t2TurnOff equ $9001
t2BoxOverrideOff equ $9002
t2BoxOverrideOn equ $9003
t2GetCurState equ $9004
t2StartupTools equ $9005
t2ShutdownTools equ $9006
t2ShareWord equ $9007
t2SetBlinkProc equ $9008
t2GetNoBlankCursors equ $9009
t2BkgBlankNow equ $900A
t2GetBuffers equ $900B
t2GetVersion equ $900C
* T2 Private IPC
reqDLZSS equ $8007
t2PrivGetProcs equ $9020
* DataField equates.
SetFieldValue equ $8000 ;custom control messages that are
GetFieldValue equ $8001 ; accepted by DataField
* Flag word passed to modules at loadsetupT2 time...
mfOverrideSound equ $0001 ; bit 0. 1=override sound, 0=sound ok

View File

@ -0,0 +1,503 @@
/*
** Ball, Release v1.0 - 19 July 1993.
** Initial release for KansasFest '93.
** Release v1.1 - 8 July 1994.
** Sound routine oversights fixed and other misc. improvements.
**
** C Source Code - "ball.cc" - Main Source Segment (4 spaces = 1 tab)
**
** A Twilight II module by James C Smith and James R Maricondo.
** Parts based off the original T2 C shell by Josef Wankerl.
** Nothing fancy, this is mainly for demo/example purposes only!
**
** Copyright 1993-94 DigiSoft Innovations, All Rights Reserved.
**
** Permission granted to use this source in any module designed for
** Twilight II for the Apple IIGS.
*/
/* pragmas */
#pragma keep "Ball.d"
#pragma cdev Ball
#pragma optimize -1
#pragma debug 0
/* defines */
#define ballCtlList 1l
#define RedStr 1l
#define BlueStr 2l
#define GreenStr 3l
#define PurpleStr 4l
#define YellowStr 5l
#define TurquoiseStr 6l
#define ballColorStr 10l
#define useSoundStr 20l
#define colorMenu 1l
#define colorCtl 1l
#define useSoundCtl 2l
#define ballStrCtl 3l
#define ballIconCtl 4l
#define ballLineCtl 5l
#define blueMenuItem 1l
#define greenMenuItem 2l
#define redMenuItem 3l
#define turquoiseMenuItem 4l
#define purpleMenuItem 5l
#define yellowMenuItem 6l
typedef struct rSoundSampleType {
int SoundFormat;
int WaveSize;
int RealPitch;
int StereoChannel;
unsigned int SampleRate;
char StartOfWaveData;
};
/* includes */
#include "T2.h" /* include the C twilight II header file */
#include <quickdraw.h>
#include <control.h>
#include <resources.h>
#include <orca.h> /* for toolerror only */
#include <memory.h>
#include <sound.h>
#include <locator.h>
#include <loader.h>
#include <misctool.h> /* for SysBeep only */
#pragma lint -1
/* prototypes */
LongWord Ball(LongWord, LongWord, Word);
LongWord MakeT2Ball(void);
void LoadSetupT2Ball(void);
void SaveConfigResource(char *, Word);
Word LoadConfigResource(char *, Word);
LongWord HitT2Ball(LongWord);
void SaveT2Ball(void);
void make_palette(int, Word *);
handle LoadASound(unsigned long ResID, word *);
void PlayASound(handle, int, word);
void cycle(void);
/* globals */
Word MyID; /* our memory manager ID */
Word soundStatus; /* boolean: old status of sound tool */
char *ConfigNameString="\pBall Setup"; /* rName to save config data under */
unsigned int BallColor, SoundFlag;
Word *movePtr; /* TRUE when we should exit the module */
Word SetupFileNumber;
GrafPortPtr SetupWindow;
Long X,Y,XV,YV, BallSize, GravityValue;
Rect MyRect;
Word MyColorTable[16];
Handle SoundHandleBoing; /* handle to the boing rSound */
Word BoingFreq; /* (converted) frequency of boing */
struct rSoundSampleType *SoundPtr;
Word LastGen, GenNum=0;
struct SoundParamBlock SoundPB;
/* this is the structure that allows us to have T2 convert the rSound header
frequency to a frequency we can pass to FFStartSound */
struct freqOffsetOut FreqOut;
/* other source files */
#include "config.cc"
/* main functions */
/*
** BlankT2 message handler: Do the animation!
*/
LongWord BlankT2Ball(void) {
unsigned int temp;
int color = 0;
int bounce = 0;
int cycleIt = 0;
struct startupToolsOut ballToolsOut;
Ptr ballToolsOutP = (Ptr) &ballToolsOut;
/* Start the sound tools if we need to */
/* Note that ball will only use sound if WE start the sound tools ourselves.
If they were started by someone else, it's not safe to use them. */
soundStatus = SoundToolStatus();
if (!soundStatus) {
SendRequest(t2StartupTools, stopAfterOne+sendToName, (long) toT2Str,
(long) (((long) MyID<<16) + startshut_sound),
(Ptr) ballToolsOutP);
if (ballToolsOut.errors) { /* if error starting up, bail out! */
SysBeep();
return (LongWord) NULL;
}
}
make_palette(BallColor, &MyColorTable[0]);
SetColorTable(0, MyColorTable);
BallSize=10;
GravityValue=8000;
X=100<<16;
Y=15<<16;
XV=4<<16;
YV=0;
SetPenMode(modeCopy);
while (!(*movePtr)) { /* until MovePtr is true, do it! */
YV+=GravityValue; /* increase gravity */
X+=XV; /* update x velocity */
Y+=YV; /* update y velocity */
if( (X+BallSize > (320<<16)) | (X-BallSize<0) ) {
XV=-XV; /* bounce off the sides */
if (X+BallSize > (320<<16)) /* boing! */
PlayASound(SoundHandleBoing, 0, BoingFreq); /* right boing */
else PlayASound(SoundHandleBoing, 1, BoingFreq);/* left boing */
}
if( (Y+BallSize > (200<<16)) | (Y-BallSize<0) ) {
YV=-YV; /* bounce off the bottom */
bounce++; /* increment bottom bounce counter */
}
MyRect.v1=(Y>>16)-BallSize; /* move the ball! */
MyRect.h1=(X>>16)-BallSize;
MyRect.v2=(Y>>16)+BallSize;
MyRect.h2=(X>>16)+BallSize;
color = (color+1)&0xF;
if (!color) color = 1; /* no black! */
SetSolidPenPat(color); /* draw the ball! */
PaintOval(&MyRect);
if (((++cycleIt)&3)==0) /* cycle every 4th time */
cycle();
if (bounce > 30) { /* restart from beginning */
GravityValue=8000;
X=X>>1;
Y=15<<16;
XV=4<<16;
YV=0;
bounce = 0;
ClearScreen(0);
}
}
/* Shutdown the sound tools if we started them... */
if (!soundStatus)
SendRequest(t2ShutdownTools, stopAfterOne+sendToName, (long) toT2Str,
(long) startshut_sound,
(long) NULL);
/* No error occurred, so return a NULL handle */
return (LongWord) NULL;
}
/*
** cycle - do the color cycling - quick and dirty assembly
*/
void cycle(void) {
Word temp;
asm {
lda 0xe19e02
sta temp
lda 0xe19e04
sta 0xe19e02
lda 0xe19e06
sta 0xe19e04
lda 0xe19e08
sta 0xe19e06
lda 0xe19e0a
sta 0xe19e08
lda 0xe19e0c
sta 0xe19e0a
lda 0xe19e0e
sta 0xe19e0c
lda 0xe19e10
sta 0xe19e0e
lda 0xe19e12
sta 0xe19e10
lda 0xe19e14
sta 0xe19e12
lda 0xe19e16
sta 0xe19e14
lda 0xe19e18
sta 0xe19e16
lda 0xe19e1a
sta 0xe19e18
lda 0xe19e1c
sta 0xe19e1a
lda 0xe19e1e
sta 0xe19e1c
lda temp
sta 0xe19e1e
};
}
/*
** make_palette-given a color like $100 or $110, create a whole gradient
** palette - e.g. $100, $200, ... $F00; or $110, $220 .. $FF0, etc
*/
void make_palette(int base, Word * palette) {
Word color = base;
int i;
*palette = 0;
for (i = 1; i<=15; i++) {
palette++;
*palette = color;
color += base;
}
}
/*
** SaveT2 message handler: Save our configuration to disk
*/
void SaveT2Ball(void) {
Word OptionWord;
Word FileNumber;
/* Save current resource file and switch in Twilight.Setup */
FileNumber = GetCurResourceFile ();
SetCurResourceFile (SetupFileNumber);
/* Get control values */
BallColor = GetCtlValue (GetCtlHandleFromID (SetupWindow, colorCtl));
SoundFlag = GetCtlValue (GetCtlHandleFromID (SetupWindow, useSoundCtl));
/* combine them to our 2 byte option word format */
OptionWord = BallColor;
if (SoundFlag)
OptionWord |= 0x8000;
/* Save control values */
SaveConfigResource(ConfigNameString, OptionWord);
/* Restore old resource file */
SetCurResourceFile (FileNumber);
}
/*
** HitT2 message handler: enable save when the popup or check box have been
** changed
*/
LongWord HitT2Ball(LongWord ControlHit) {
LongWord EnableFlag = 0L;
if (ControlHit == 1 || ControlHit == 2)
EnableFlag = 1L;
return EnableFlag;
}
/*
** MakeT2 message handler: make our setup controls and set them to their
** last saved or default values
*/
LongWord MakeT2Ball(void) {
Word FileNumber;
FileNumber = GetCurResourceFile ();
SetCurResourceFile(SetupFileNumber);
LoadSetupT2Ball();
SetCurResourceFile(FileNumber);
NewControl2(SetupWindow, resourceToResource, (long) ballCtlList);
SetCtlValue(BallColor, GetCtlHandleFromID (SetupWindow, colorCtl));
SetCtlValue(SoundFlag, GetCtlHandleFromID (SetupWindow, useSoundCtl));
return 5L; /* tell T2 we just made 5 controls with ids from 1 thru 5 */
}
/*
** LoadSetupT2 message handler: load the last saved setup values from the
** Twilight.Setup file on disk
*/
void LoadSetupT2Ball(void) {
Word OptionWord;
/* Option Word format
* 0x0FFF = ball color, in a format that can be passed to make_palette
* (above) - also the menu item ID of the currently selected
* color
* 0x8000 = (bit 15) boolean - 1=use sound, 2=no sound
*/
OptionWord = LoadConfigResource (ConfigNameString, 0x8110);
BallColor = OptionWord & 0x0FFF;
SoundFlag = OptionWord & 0x8000;
}
/*
** LoadASound - load an rSound from our resource fork and use a T2 IPC
** request to have T2 convert the rSound header frequency to
** a frequency we can use with FFStartSound
**
** NOTE that our resource fork must be opened beforehand!!!
*/
handle LoadASound(unsigned long ResID, word *freqOffset) {
handle WorkHandle;
WorkHandle=LoadResource(rSoundSample, ResID);
if(toolerror())
return 0;
DetachResource(rSoundSample, ResID);
SetHandleID(MyID, WorkHandle);
HLock(WorkHandle);
SoundPtr=(void *) *WorkHandle;
SendRequest(t2CalcFreqOffset, stopAfterOne+sendToName, (longword) toT2Str,
(long) (SoundPtr->RealPitch),(void *) &FreqOut);
*freqOffset=FreqOut.freqOffset;
HUnlock(WorkHandle);
return WorkHandle;
}
/*
** PlayASound - play a sound effect. Note that this routine only uses a
** maximum of 2 oscillators (you can change it :-)
*/
void PlayASound(handle SoundHandle, int Channel, word Frequency) {
/* there are three cases where we will not have sound:
1) the global sound override flag is set (in Setup: Options)
2) the use sound checkbox is unchecked (in Ball's own options screen)
3) the sound manager was already started when we were called (e.g. we
didn't have to start it ourselves). in this case, it's not safe to use
sound effects
*/
if((!SoundFlag)||(soundStatus)) /* are we supposed to have sound FX? */
return;
HLock(SoundHandle);
SoundPtr=(void *) *SoundHandle;
SoundPB.waveStart=&SoundPtr->StartOfWaveData;
SoundPB.waveSize=SoundPtr->WaveSize;
SoundPB.freqOffset=Frequency;
SoundPB.docBuffer=GenNum<<15;
SoundPB.bufferSize=0x6;
SoundPB.nextWavePtr=NULL;
SoundPB.volSetting=255;
FFStopSound((word) (1<<(GenNum&1))); /* stop anything from earlier */
FFStartSound((word) (Channel<<12 | ((GenNum&1)<<8) | ffSynthMode),
(Pointer) &SoundPB);
++GenNum; /* use a different generator next time */
HUnlock(SoundHandle);
}
/*
** The Main Message Handler! This dispatches the appropriate handler!
*/
LongWord Ball(LongWord data2, LongWord data1, Word message) {
LongWord Result = 1L;
word MyResFile, OldResFile;
MyID=MMStartUp(); /* get our memory ID for the procs to use */
switch (message) {
case MakeT2: /* draw and set our setup controls */
SetupWindow = (GrafPortPtr) data1;
SetupFileNumber = (Word) data2;
Result = MakeT2Ball();
break;
case BlankT2: /* blank the screen */
movePtr=(Word *) data1;
Result = BlankT2Ball();
break;
case SaveT2: /* save the setup */
SaveT2Ball();
break;
case LoadSetupT2: /* load the setup */
LoadSetupT2Ball(); /* first actually load it then load sound */
if ((int)data2&lmiOverrideSound==lmiOverrideSound)
SoundFlag=0; /* respect global sound override flag */
if (SoundFlag) { /* load the rSound! */
OldResFile=GetCurResourceFile(); /* open our rfork! */
MyResFile=OpenResourceFile(1 /* read only */,
NULL, LGetPathname2(MyID, 0x0001));
SoundHandleBoing= LoadASound(1, &BoingFreq);
CloseResourceFile(MyResFile); /* close our rfork */
SetCurResourceFile(OldResFile); /* restore old resfile */
}
break;
case HitT2: /* handle control hit */
Result = HitT2Ball(data2);
break;
case UnloadSetupT2: /* unload our setup */
if (SoundFlag) /* dispose the sound, if loaded */
DisposeHandle(SoundHandleBoing);
break;
case KillT2: /* don't do anything special for KillT2 */
break;
}
return Result;
}

View File

@ -0,0 +1,59 @@
Well, here it is, the first of the long awaited Twilight II sample
source code files!
This is a very simple module.. Preferably the "use sound" checkbox
should be a popup or something that allows the user to set the sound
volume. This module could be elaborated on in many ways - feel free to
try it! :-)
Included here, part of Ball (C version), are 13 files:
ball.info - this information file
ball.rez - the resources for the ball module (Rez source code)
ball.cc - the ball module source (C source code)
config.cc - more ball module source (C source code)
makefile - a makefile to put the whole thing together
rSound.bin - the "boing" sound (a binary image of the rSound)
ball - a compiled version of the ball module (ready to run!)
ball.d - a compiled version of the ball module's data fork
ball.r - a compiled version of the ball module's resource fork
t2.h - Twilight II specific C header information (C header file)
t2common.equ - Twilight II specific assembly header information (not used by ball, but here for your uses)
t2common.rez - Twilight II specific Rez header information (Rez header file)
blank.template - the resource fork of blank.template contains a copy of the Twilight II setup window, so you can layout your setup screen controls graphically with Genesys and then save them to Rez source and fine-tune them manually (NOTE: You cannot use Genesys exclusively to create a Twilight II module's resource fork, because Genesys cannot create the rT2ModuleFlags resource required, and Genesys will not properly set your control IDs to the sequential format T2 requires)
NOTE: Rez and Orca/C are currently required.
Version 1.0: July 19, 1993
Version 1.1: July 8, 1994
---
Also included currently in the Twilight II v1.1 Developer Kit, but
available separately, is the Twilight II Generation 2 Module Format
(G2MF) Reference. This AWGS file documents every aspect of the module
format in detail. You NEED THIS FILE too if you plan on writing
Twilight II modules. You can get it from the same place where you
got Ball! If you can't find it, email us below.
Coming SOON:
- Other language versions of the Ball module.
- Better documentation of the Twilight II IPC requests that modules can use!
Feel free to use all source here to develop Twilight II modules. All
other uses are prohibited. All developer kit files are Copyright Jim
Maricondo, All Rights Reserved.
For more information on Twilight II, contact:
DigiSoft Innovations
P.O. Box 380
Trumbull, CT 06611-0380
Phone 203.375.0837
Email: digisoft@aol.com (intenet), DIGISOFT (GEnie), DigiSoft (AO),
DYAJIM (Delphi)
Twilight II is also sold by Big Red Computer Club and Resource Central.

View File

@ -0,0 +1,317 @@
/*
** Ball, Release v1.1 - 8 July 1994
** Rez Source Code - "ball.rez" - Rez Code
**
** Much of this code generated with Foundation & Genesys.
** If you don't have Foundation, BUY IT NOW!
** It's invaluable (and necessary) for programming the GS.
**
** Copyright 1993-94 DigiSoft Innovations, All Rights Reserved.
**
** Permission granted to use this source in any module designed for
** Twilight II for the Apple IIGS.
*/
#include "types.rez"
#include "T2Common.Rez" // Include Twilight II rez header file
#define ballCtlList 1
#define RedStr 1
#define BlueStr 2
#define GreenStr 3
#define PurpleStr 4
#define YellowStr 5
#define TurquoiseStr 6
#define ballColorStr 10
#define useSoundStr 20
#define colorMenu 1
#define colorCtl 1
#define useSoundCtl 2
#define ballStrCtl 3
#define ballIconCtl 4
#define ballLineCtl 5
#define blueMenuItem 1
#define greenMenuItem 2
#define redMenuItem 3
#define turquoiseMenuItem 4
#define purpleMenuItem 5
#define yellowMenuItem 6
// --- Twilight II module flags resource
resource rT2ModuleFlags (moduleFlags) {
fSetup + // we support setup
fFadeOut + // we want the screen to be faded out beforehand
fFadeIn + // we want the screen to fade in at the end
fLeavesUsableScreen + // we leave a "usable" screen (see G2MF)
fGrafPort320, // module flags
$01, // enabled flag (unimplemented right now)
$0110, // minimum T2 version required - v1.1 minimum
NIL, // reserved
"Ball" // module name
};
// --- rVersion Templates
resource rVersion (moduleVersion) {
{1,1,0,release,0}, // Version 1.1 release
verUS, // US Version
"T2 Ball (Sample) Module", // program's name
"By Jim Maricondo\n"
"Copyright 1993-94, Jim Maricondo." // copyright notice
};
// --- Ball Icon Definition
resource rIcon (moduleIcon) {
$8000, // kind
$0014, // height
$0016, // width
$"F00000000000000000000F"
$"0FFFFFFFFFFFFFFFFFFFF0"
$"0F044000000000000000F0"
$"0F444400000DDD000000F0"
$"0F44770000DDDDD00000F0"
$"0F0777700ADDDDD00000F0"
$"0F077660BBDDDDD00000F0"
$"0F00666BBBBDDD030000F0"
$"0F0066EBBBB003000000F0"
$"0F000EEEBB0000330000F0"
$"0F000EEEE00000300000F0"
$"0F0000EE000000033000F0"
$"0FFFFFFFFFFFFFFFFAFFF0"
$"0000000000000000000000"
$"F0FFFFFFFFFFFFFFFFFF0F"
$"F0FFFFFFFFFFFFFFFFFF0F"
$"F0FF4AFFFFFFFFFFFFFF0F"
$"F0CCCCCCCCCCCCCCCCCC0F"
$"F0FFFFFFFFFFFFFFFAFF0F"
$"F00000000000000000000F",
$"0FFFFFFFFFFFFFFFFFFFF0"
$"FFFFFFFFFFFFFFFFFFFFFF"
$"FFFFFFFFFFFFFFFFFFFFFF"
$"FFFFFFFFFFFFFFFFFFFFFF"
$"FFFFFFFFFFFFFFFFFFFFFF"
$"FFFFFFFFFFFFFFFFFFFFFF"
$"FFFFFFFFFFFFFFFFFFFFFF"
$"FFFFFFFFFFFFFFFFFFFFFF"
$"FFFFFFFFFFFFFFFFFFFFFF"
$"FFFFFFFFFFFFFFFFFFFFFF"
$"FFFFFFFFFFFFFFFFFFFFFF"
$"FFFFFFFFFFFFFFFFFFFFFF"
$"FFFFFFFFFFFFFFFFFFFFFF"
$"FFFFFFFFFFFFFFFFFFFFFF"
$"0FFFFFFFFFFFFFFFFFFFF0"
$"0FFFFFFFFFFFFFFFFFFFF0"
$"0FFFFFFFFFFFFFFFFFFFF0"
$"0FFFFFFFFFFFFFFFFFFFF0"
$"0FFFFFFFFFFFFFFFFFFFF0"
$"0FFFFFFFFFFFFFFFFFFFF0";
};
// module message
resource rTextForLETextBox2 (moduleMessage) {
TBLeftJust
TBBackColor TBColorF
TBForeColor TBColor1
"Ball"
TBForeColor TBColor0
" demonstrates how to write a Twilight II module.\n"
"Full source code available!"
};
// --- Ball Control List Definition
resource rControlList (ballCtlList) {
{
colorCtl,
useSoundCtl,
ballStrCtl,
ballIconCtl,
ballLineCtl,
};
};
// --- Control Templates
// NOTE: IDs _must_ be numbered sequentially from 1..maximumID
resource rControlTemplate (colorCtl) {
1, // ID
{ 61, 74, 0, 0}, // rect
popUpControl {{
$0040, // flag
$1002, // moreFlags
NIL, // refCon
NIL, // titleWidth
colorMenu, // menuRef
$01FF, // initialValue
NIL // colorTableRef
}};
};
resource rControlTemplate (useSoundCtl) {
2, // ID
{ 75, 78, 84,188}, // rect
checkControl {{
NIL, // flag
fCtlProcNotPtr+fCtlWantsEvents+refIsResource, // moreFlags
NIL, // refCon
UseSoundStr, // titleRef
NIL, // initialValue
0, // colorTableRef
{"U","u",$0100,$0100} // key equivalents
}};
};
resource rControlTemplate (ballStrCtl) {
3, // ID
{ 49,114, 59,209}, // rect
statTextControl {{
NIL, // flag
$1002, // moreFlags
NIL, // refCon
1 // textRef (rLeTextBox2)
}};
};
resource rControlTemplate (ballIconCtl) {
4, // ID
{ 26,138, 49,186}, // rect
iconButtonControl {{
$000C, // flag
$1020, // moreFlags
NIL, // refCon
moduleIcon, // iconRef
NIL, // titleRef
NIL, // colorTableRef
NIL // displayMode
}};
};
resource rControlTemplate (ballLineCtl) {
5, // ID
{ 53, 60, 92,274}, // rect
rectangleControl {{
$FF02, // flag (%10 = black pattern)
fCtlProcNotPtr, // moreFlags (required values)
NIL // refCon
}};
};
// --- rPString Templates
resource rPString (UseSoundStr) {
"Use Sound"
};
resource rPString (ballColorStr) {
" Ball Color: "
};
resource rPString (RedStr) {
"Red"
};
resource rPString (BlueStr, $C018) {
"Blue"
};
resource rPString (GreenStr, $C018) {
"Green"
};
resource rPString (PurpleStr, $C018) {
"Purple"
};
resource rPString (YellowStr, $C018) {
"Yellow"
};
resource rPString (TurquoiseStr, $C018) {
"Turquoise"
};
// --- Menu Definitions
resource rMenu (colorMenu) {
1, // menuID
$A000, // menuFlag
ballColorStr, { // menuTitleRef
redMenuItem,
blueMenuItem,
greenMenuItem,
purpleMenuItem,
yellowMenuItem,
turquoiseMenuItem
};
};
// --- Menu Item Definitions
resource rMenuItem (blueMenuItem, $C018) {
$0001, // itemID
"","", // itemChar, itemAltChar
NIL, // itemCheck
$8000, // itemFlag
BlueStr // itemTitleRef
};
resource rMenuItem (greenMenuItem, $C018) {
$0010, // itemID
"","", // itemChar, itemAltChar
NIL, // itemCheck
$8000, // itemFlag
GreenStr // itemTitleRef
};
resource rMenuItem (purpleMenuItem, $C018) {
$0101, // itemID
"","", // itemChar, itemAltChar
NIL, // itemCheck
$8000, // itemFlag
PurpleStr // itemTitleRef
};
resource rMenuItem (yellowMenuItem, $C018) {
$0110, // itemID
"","", // itemChar, itemAltChar
NIL, // itemCheck
$8000, // itemFlag
YellowStr // itemTitleRef
};
resource rMenuItem (turquoiseMenuItem, $C018) {
$0011, // itemID
"","", // itemChar, itemAltChar
NIL, // itemCheck
$8000, // itemFlag
TurquoiseStr // itemTitleRef
};
resource rMenuItem (redMenuItem) {
$0100, // itemID
"","", // itemChar, itemAltChar
NIL, // itemCheck
$8000, // itemFlag
RedStr // itemTitleRef
};
// --- rTextForLETextBox2 Templates
resource rTextForLETextBox2 (1) {
" Ball Options "
};
// finally, the ball sound - read in a binary image of the rSound
read rSoundSample (0x1,locked,nocrossbank,nospecialmemory) "rSound.bin";