gtBASIC

Using, learning, programming and modding the Gigatron and anything related.
Forum rules
Be nice. No drama.
wbushby
Posts: 208
Joined: 16 Jul 2021, 10:59

Re: gtBASIC

Post by wbushby »

OK, thanks for that info. I can then develop and test the code. I was starting to get frustrated waiting for my new man cave to be finished. It is running about 4 months behind schedule.
wbushby
Posts: 208
Joined: 16 Jul 2021, 10:59

Re: gtBASIC

Post by wbushby »

@axelb
You have this line for getting controller buttons.
button.lo = get("SERIAL_RAW") XOR 255
I thought controller buttons were obtained using "BUTTON_STATE" ?
bmwtcu
Posts: 145
Joined: 01 Nov 2018, 12:02

Re: gtBASIC

Post by bmwtcu »

I think what he's suggesting is to first read all 8 bits of the raw famicom serial data one time into a variable that you can use with follow-up conditionals to parse, which would enable you to theoretically handle all 256 possible combinations of simultaneous key presses.
Attachments
input.JPG
input.JPG (14.66 KiB) Viewed 599 times
SERIAL_RAW.JPG
SERIAL_RAW.JPG (11.68 KiB) Viewed 600 times
wbushby
Posts: 208
Joined: 16 Jul 2021, 10:59

Re: gtBASIC

Post by wbushby »

I understand now. I hadn't tied SERIALRAW and BUTTONSTATE together when I read that before.
I have found that BUTTONSTATE provides the information showing direction key and A key being simultaneously pressed so either can be used it seems.
at67
Site Admin
Posts: 647
Joined: 14 May 2018, 08:29

Re: gtBASIC

Post by at67 »

There's a good explanation of the difference between the two registers here, by Marcel: https://forum.gigatron.io/viewtopic.php?t=138

1) serialRaw is the raw bits read from the shift register every 60Hz.
2) buttonState is an edge triggered representation of serialRaw that the native ROM creates for one shot events.
3) Axel's first line of code uses XOR 255 to invert the result read as both serialRaw and buttonState are active low logic
wbushby
Posts: 208
Joined: 16 Jul 2021, 10:59

Re: gtBASIC

Post by wbushby »

Here is an upgrade to Manic Miner that allows you to walk and jump at the same time when using a controller. 'A' button for jump.
Attachments
manicminer64k41v1.3.gt1
(58.54 KiB) Downloaded 54 times
bmwtcu
Posts: 145
Joined: 01 Nov 2018, 12:02

Re: gtBASIC

Post by bmwtcu »

Works much better!
axelb
Posts: 41
Joined: 07 Jan 2021, 06:27

Re: gtBASIC

Post by axelb »

Your new version is now working great with my controller. Thank you!
wbushby
Posts: 208
Joined: 16 Jul 2021, 10:59

Re: gtBASIC vX0

Post by wbushby »

I have discovered a problem with division on vX0 of gtBasic

I have been experimenting with minimal code:

This code produces:

sceneType = Scene / 1 PRODUCES 2050 X

sceneType = Scene / 2 PRODUCES 98 Correct

sceneType = Scene / 4 PRODUCES 1536 X

sceneType = Scene / 8 PRODUCES 1025 X

sceneType = Scene / 16 PRODUCES 12 Correct

The full code:

_runtimePath_ "../runtime"
_runtimeStart_ &h7FFF
_arraysStart_ &h7FFF
_codeRomType_ ROMvX0



' initial value for the random number generator:
CONST RAND_SEED = 196 ' defines the start scene of the game
' 11 000 100
' next scene to the right
' 10 110 001
' next scene to the left
' 00 000 001



Scene% = RAND_SEED ' Start Scene Code

sceneType% = 0 ' Type of the scene (0..7)


' Initialise system

START:

CLS

AT 0,0
SET FG_COLOUR, 63

PRINT "Scene = ";Scene
sceneType = Scene / 1
PRINT "SceneType1 = ";sceneType
sceneType = Scene / 2
PRINT "SceneType2 = ";sceneType
sceneType = Scene / 4
PRINT "SceneType4 = ";sceneType
sceneType = Scene / 8
PRINT "SceneType8 = ";sceneType
sceneType = Scene / 16
PRINT "SceneType16 = ";sceneType



MAINLOOP:


WAIT 10

GOTO MAINLOOP

END
wbushby
Posts: 208
Joined: 16 Jul 2021, 10:59

Re: gtBASIC

Post by wbushby »

Interesting result when I compiled to ROMv5A with the vX0 gtBasic and run with vX0 emulator

sceneType = Scene / 1 PRODUCES 196 correct

sceneType = Scene / 2 PRODUCES 2 X

sceneType = Scene / 4 PRODUCES 49 X

sceneType = Scene / 8 PRODUCES 24 Correct

sceneType = Scene / 16 PRODUCES 12 Correct
Post Reply