gtBASIC

Using, learning, programming and modding the Gigatron and anything related.
Forum rules
Be nice. No drama.
at67
Posts: 389
Joined: 14 May 2018, 08:29

Re: gtBASIC

Post by at67 »

You should probably never see this, it means the Assembler is either trying to compile native assembler, (i.e. dot instructions, .LD, .ST etc), or that it couldn't save the resultant .gt1 file to the file system.

Basically compiling, linking, optimising and assembly were all successful, but then the process faltered right at the last step.

Check for any errant dot instructions between asm-endasm pairs or a full disk I guess, it's probably also best if you send me the source again, there's also a good chance you have found another bug.

I'll separate out that error message into two distinct error messages for the next version of the compiler.
wbushby
Posts: 50
Joined: 16 Jul 2021, 10:59

Re: gtBASIC

Post by wbushby »

Finally have all the variables converted to arrays. The intermittent issues have not recurred so can't send you an example at the moment.

I am sure at the size of file I am working with and the scope of the changes I will trigger it again.
wbushby
Posts: 50
Joined: 16 Jul 2021, 10:59

Re: gtBASIC

Post by wbushby »

Is it possible to change sprite colours within the program ?
I have 2 colour sprites and I would like to change background colour and foreground colour separately

Also can you recommend a good TGA editor ?
at67
Posts: 389
Joined: 14 May 2018, 08:29

Re: gtBASIC

Post by at67 »

The only way to change the colour of sprites/blits quickly is to switch between two separately stored images in RAM, you could write code to modify the image contents in RAM, but that would be horribly slow, (even in assembly).

I use Paint.NET on Windows and GIMP under Linux.
wbushby
Posts: 50
Joined: 16 Jul 2021, 10:59

Re: gtBASIC

Post by wbushby »

I am experimenting with the interrupt functionality but am experiencing interference with the screen display when using it.

Here is an example where it erases most of the 'Counter = XXXX' on the screen.

Code: Select all

_runtimePath_ "../../runtime"
_runtimeStart_ &hFFFF
_arraysStart_ &hFFFF
_codeRomType_ ROMv5a

'free string work area, (better not use any of the string runtime!)
free STRINGWORKAREA

'audio fix for ROMv5a
POKE &h21, peek(&h21) OR 3

Counter = 0

MODE 1
SET FGBG_COLOUR, &h3F00
CLS

INIT SOUND

LOOP:
	
	AT 10,10
	PRINT "Counter = ";Counter
	WAIT 500

	GOTO LOOP


SOUND:
	INC Counter

	IF Counter >= 10000 THEN Counter = 0


	RET
wbushby
Posts: 50
Joined: 16 Jul 2021, 10:59

Re: gtBASIC

Post by wbushby »

I have a question. What is FRAME_COUNT ?

Is there a list of these system variables anywhere ?
at67
Posts: 389
Joined: 14 May 2018, 08:29

Re: gtBASIC

Post by at67 »

GET
• GET is a function that accepts a string literal describing a system variable to get and an optional
number of parameters used by that system variable.
• System variable’s available for get.

Code: Select all

bs = GET(“BUTTON_STATE”)
‘ returns the current BUTTON_STATE register, &h00 >= bs <= &hFF
cm = GET(“CHANNEL_MASK”)
‘ returns the current sound channel mask, &h00 >= cm <= &h03
cx = GET(“CURSOR_X”)
‘ returns the current cursor’s x position, 0 >= cx <= 255
cy = GET(“CURSOR_Y”)
‘ returns the current cursor’s y position, 0 >= cy <= 255
cxy = GET(“CURSOR_XY”)
‘ returns the current cursor’s xy position, &h0000 >= cxy <= &hFFFF
bc = GET(“BG_COLOUR”)
‘ returns the current background colour, &h00 >= bc <= &hFF
fc = GET(“FG_COLOUR”)
‘ returns the current foreground colour, &h00 >= fc <= &hFF
fbc = GET(“FGBG_COLOUR”)
‘ returns the current fg and bg colours, &h0000 >= fbc <= &hFFFF
fc = GET(“FRAME_COUNT”)
‘ returns the current FRAME_COUNT register, &h00 >= fc <= &hFF
ls = GET(“LED_STATE”)
‘ returns the current LED state, 0 >= ls <= 255
lt = GET(“LED_TEMPO”)
‘ returns the current LED tempo, 0 >= lt <= 255
ms = GET(“MEM_SIZE”)
‘ returns the current size of memory, &h80 = 32K, &h00 = 64K
ms = GET(“MIDI_STREAM”)
‘ returns the current MIDI stream address, &h0000 >= ms <= &hFFFF
n = GET(“MIDI_NOTE”, m)
‘ returns the midi note corresponding to the index ‘m’, midi indices
‘ start at 12 and end at 106, (this is the entire range of the Gigatron)
n = GET(“MUSIC_NOTE”, i)
‘ returns the note corresponding to the index ‘i’, music indices start
‘ at 0 and end at 94, (this is the entire range of the Gigatron)
r0 = GET(“RAND0”)
‘ returns the current RAND0 register, &h00 >= r0 <= &hFF
r1 = GET(“RAND1”)
‘ returns the current RAND1 register, &h00 >= r1 <= &hFF
r2 = GET(“RAND2”)
‘ returns the current RAND2 register, &h00 >= r2 <= &hFF
rn = GET(“ROM_NOTES”)
‘ returns the start address of the ROM note table,
‘ &h0000 >= rn <= &hFFFF
a = 0 : a = GET(“ROM_READ_DIR”, a) ‘ only available in >= ROMv5a
‘ returns the address of the next main menu application, ‘a’ is the
‘ address of the current application or 0 for the start of the list
rt3 = GET(“ROM_TEXT32”)
‘ returns the address of the ROM 32+ font table, &h0000 >= rt3 <= &hFFFF
rt8 = GET(“ROM_TEXT82”)
‘ returns the address of the ROM 82+ font table, &h0000 >= rt8 <= &hFFFF
rt = GET(“ROM_TYPE”)
‘ returns the current ROM type, &h00 >= rt <= &hF8
sch0 = GET(“SND_CHN0”)
‘ returns the current address of sound channel0,
‘ &h0000 >= sch0 <= &hFFFF
sch1 = GET(“SND_CHN1”)
‘ returns the current address of sound channel1,
‘ &h0000 >= sch1 <= &hFFFF
sch2 = GET(“SND_CHN2”)
‘ returns the current address of sound channel2,
‘ &h0000 >= sch2 <= &hFFFF
sch3 = GET(“SND_CHN3”)
‘ returns the current address of sound channel3,
‘ &h0000 >= sch3 <= &hFFFF
a = GET(“SPRITE_LUT”, s) ‘ only available in >= ROMv3
‘ returns the address of the sprite corresponding to the sprite id ‘s’
sr = GET(“SERIAL_RAW”)
‘ returns the current SERIAL_RAW register, &h00 >= sr <= &hFF
st = GET(“SOUND_TIMER”)
‘ returns the current sound timer, 0 >= st <= 255
te = GET(“TIME_EPOCH”)
‘ returns the current time epoch, where time begins
tm = GET(“TIME_MODE”)
‘ returns the current time mode, tm = 12 or tm = 24
ts = GET(“TIME_S”)
‘ returns the current time’s seconds value, 0 >= ts <= 59
tm = GET(“TIME_M”)
‘ returns the current time’s minutes value, 0 >= tm <= 59
th = GET(“TIME_H”)
‘ returns the current time’s hours value, 0 >= th <= 12/24
t = GET(“TIMER”)
‘ returns the current timer’s tick value, 0 >= t <= 32767
t = GET(“TIMER_PREV”)
‘ returns the internal timer’s tick value, 0 >= t <= 32767
vac = GET(“VAC”)
‘ returns the current vCPU accumulator, &h0000 >= vac <= &hFFFF
vlr = GET(“VLR”)
‘ returns the current vCPU leaf register, &h0000 >= vlr <= &hFFFF
vpc = GET(“VPC”)
‘ returns the current vCPU program counter, &h0000 >= vpc <= &hFFFF
vsp = GET(“VSP”)
‘ returns the current vCPU stack pointer, &h00 >= vsp <= &hFF
vbp = GET(“VBLANK_PROC”) ‘ only available in >= ROMv5a
‘ returns the current VBlank interrupt address, &h0200 >= vbp <= &hFFFF
vbf = GET(“VBLANK_FREQ”) ‘ only available in >= ROMv5a
‘ returns the current VBlank interrupt frequency, 1 >= vbf <= 255
vram = GET(“V_RAM”)
‘ returns the start address of video memory, &h0000 >= vram <= &hFFFF
vtp = GET(“V_TOP”)
‘ returns the address of the V_TOP register, &h0000 >= vtp <= &hFFFF
vtb = GET(“V_TABLE”)
‘ returns the address of the V_TABLE register, &h0000 >= vtb <= &hFFFF
vy = GET(“VIDEO_Y”)
‘ returns the current VIDEO_Y register, &h00 >= vy <= &hFF
xm = GET(“XOUT_MASK”)
‘ returns the current XOUT register mask, &h00 >= xm <= &hFF
xr = GET(“X_RES”)
‘ returns the Gigatron’s current screen width, &h00 >= xr <= &hFF
yr = GET(“Y_RES”)
‘ returns the Gigatron’s current screen height, &h00 >= yr <= &hFF
wbushby
Posts: 50
Joined: 16 Jul 2021, 10:59

Re: gtBASIC

Post by wbushby »

I have been able to make a background sound that is a close match to the original Atari sound on my game. Running this through the VBlank interrupt process is working brilliantly.

Thank you for the list of system variables.
wbushby
Posts: 50
Joined: 16 Jul 2021, 10:59

Re: gtBASIC

Post by wbushby »

I have moved the background sound into my actual program from my test one.

I have 2 issues at moment:

1) The IRQ seems to interfere with my screen blanking out some sections to the background colour.
2) MY Game Loop appears to stop running when the background sound stars up

For issue 2 I thought I might be able to reduce the loop frequency(timeslice?) but there seems to be an issue compiling a reference to it ?

Compiler::factor() : 'Main:2578' : found an unknown symbol 'VBLANK_FREQö' : vbf = GET(ôVBLANK_FREQö)

The code I am running on interrupt is:

Code: Select all


ENGINESOUND:

'*** Play our starship's Engines sound *****************************************

	SOUND OFF

	SET SOUND_TIMER, 255

	SX = Globals(VELOCITY)									' Skip if Engines softer than noise sound pattern

	NOISESP(NOISELIFE) = 0									' Terminate noise sound pattern

	IF SX >= 128 THEN SX = 128

	Globals(AUDF1) = SX

	Globals(AUDC1) = SX + 10

	SOUND ON, 1, Globals(AUDF1), Globals(AUDC1),0

	RET
/code]
at67
Posts: 389
Joined: 14 May 2018, 08:29

Re: gtBASIC

Post by at67 »

Edit keywords.cpp on line 6190 and change the if 0 to if 1

Code: Select all

#if 0 <-- change this to 1
            // TODO: Fix this
            // (256 - n) = vblank interrupt frequency, where n = 1 to 255
            Compiler::emitVcpuAsm("LDWI", "realTS_rti + 2", false);
            Compiler::emitVcpuAsm("STW", "register0", false);
            if(Compiler::parseExpression(codeLineIndex, token1, param1) == Expression::IsInvalid)
            {
                fprintf(stderr, "Keywords::SET() : '%s:%d' : syntax error in %s : %s\n", codeLine._moduleName.c_str(), codeLineStart, token1.c_str(), codeLine._text.c_str());
                return false;
            }
            Compiler::emitVcpuAsm("STW", "register1", false);
            Compiler::emitVcpuAsm("LDWI", "256", false);
            Compiler::emitVcpuAsm("SUBW", "register1", false);
            Compiler::emitVcpuAsm("POKE", "register0", false);
#endif
I'm not sure why this code was ifdef'd out and why there is a TODO on it, but give it a try and let me know if it works, obviously instead of your interrupt running at 60Hz it will run at 60/n Hz.
Post Reply