Syntax question?

Previous topic - Next topic

erico

Hey matchy, I´m curious about this coco coding of yours, I remember an old post where you asked if anyone was into retro-coding. Can you share something visual about that? a picture maybe?

Dealing colors on coco was really something, specially on a TV.
I still have some rainbow magazines (I use to buy it and could not even read it as I knew no english by them) where they had a galley section, most of the images where done on coding, outstanding stuff...later coco max (first color photoshop worldwide?) got on the way, but still, really impressive stuff.

...I also remember a part where they had single line code showoff, people would post their solutions or full stuff coded into a single line of basic...heck, my kid´s mind was definently fried by that...reminds me a little on the Tiny Cursor Key Snippet spicepixel posted recently. This kind of optimization I guess requires too much math and logic..I wish I could.

matchy

Sure Erico (and I'm not sure if I should start another thread).  :-[

I've been experimenting with sprites and map scrolling. The Rainbow and Coco Max magazine were great and the pdfs are available to download. Coco Max is also an inspiration to recreate in glb. ;) Here is an example although I need to find my PMODE and sprite GET/PUT tests.

The way I go about it is that I type it in notepad then paste it in coco MESS emulator.
Code (glbasic) Select

' Tandy TRS-80 Color Computer BASIC
' Simple text map scrolling test

NEW
CLS

5 CLS 0

10 ' INIT
20 DIM DT$(16)
30 MX = 0
40 MY = 0
50 GOSUB 900 ' READ DATA
60 GOSUB 500 ' ANIMATE

500 ' ANIMATE
510 CLS 0
520 GOSUB 600 ' CALC MAP
530 GOSUB 700 ' DRAW MAP
580 ' GOSUB 1100 ' PAUSE
590 GOTO 500 'RETURN

600 ' CALC MAP
610 MX = MX - 1
620 IF MX < -25 THEN MX = 0
630 RETURN

700 ' DRAW MAP
710 FOR Y = 2 TO 15
720  FOR X = 0 TO 9
730   TM$ = MID$(DT$(Y + 1), X + 1 - MX, 1)
740   IF TM$ = "A" THEN TM$ = CHR$(127 + 32) : GOSUB 800 ' PRINT TILE
750   IF TM$ = "X" THEN TM$ = CHR$(127 + 16) : GOSUB 800 ' PRINT TILE
760  NEXT
770 NEXT
780 RETURN

800 ' PRINT TILE
810 PS = (Y * 32) + X
820 PRINT @PS, TM$;
830 RETURN

900 ' TEST
910 FOR N = 0 TO 15
920  READ DT$(N)
930 NEXT
940 RETURN

1000 ' DRAW MAP 2
1010 FOR Y = 0 TO 15
1020  PRINT @ Y * 32, "                   ";
1030 NEXT
1040 RETURN

1100 ' PAUSE
1110 FOR I = 0 TO 9000 : NEXT
1120 RETURN

5000 ' DATA
5010 DATA ".........................................................."
5020 DATA "...................................................AA....."
5030 DATA ".....AA............................................A......"
5040 DATA "........................................A..........A......"
5050 DATA "....................A...................A................."
5060 DATA "....................AAA.................A..........A......"
5070 DATA "......................A..................................."
5080 DATA "........AAAAA................................AA..........."
5090 DATA "........AAAAA...............................AAAA.........."
5100 DATA "............................................AAAA.........."
5110 DATA ".............................AAA.........................."
5120 DATA ".............................AAA.........................."
5130 DATA ".............................AAA................AAA......."
5140 DATA "................AAAA......................................"
5150 DATA ".......A........AAAA......................................"
5160 DATA "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
5170 DATA "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
5180 DATA "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"

RUN

Kitty Hello

I got a bit confused now, but matchy corrected my mind.
My basic understanding of "BASIC" comes from my C64 days, where functions with no return are called w/o braces:
Code (glbasic) Select

POKE 1024, 88
REM check left, top corner now
PRINT PEEK(1024)


See also the examples on the Wiki
http://en.wikipedia.org/wiki/BASIC

So, it's not inconsistent, it's BASIC.

erico

#18
Matchy,
I was expecting a picture...you know, pictures tell a thousand words...
but then you gave code, well :zzz: codes tell a thousand pictures! :)

I almost thought I would have to type all that on the mocha emulator just to fulfill my curiosity!
I knew better to follow the hint on paste code on mess..

after a few tries, damn it, it goes pasting as if someone is typing the thing! my mind is just busted, I did that my self a lot as by that time I was 10 years old :O

I will just have to paste a pic of one of the runs, it´s clear that this picture speaks 1 billion words!
heck, I´m really happy now, thanks!

ps: no poke for speed, but I get the deal from the code, I´m impressed, if I only knew this by the time I wrote my ninja giraya game...
Most of my games were characters made, a few had get/put, but memory was soooooo short for that and I knew nothing how to optimize or tile it... I succeed in only one, a game where things fell from a tree, you had to collect fruits, 6 short sprites made the deal...I wish I had the cassete with this code.

ps2: where is the time bandit remake?! I wanna see that!

[attachment deleted by admin]

matchy

I think the whole purpose of BASIC is to create an understandable form that could be simply understood by anyone unlike c or Pascal. In this example, even though brackets are used, it makes sense to use brackets to clearly distinguish that there are two points. Technically, this aspect seems to naturally override proper efficient forms in some cases.

eg1: LINE(0,0)-(128,128)
eg2: LINE 0, 0, 128, 128

erico, wow that is cool you tried it. I paste on maximum emulator speed, so it looks like 200 words per minutes are being typed. lol.



ampos

To the ones without any other language knowledge, just the old-good Basic, it is clear: brackets=returns a value. No brackets, does not.


ampos

Quote from: Kitty Hello on 2011-Oct-12
I got a bit confused now, but matchy corrected my mind.
My basic understanding of "BASIC" comes from my C64 days, where functions with no return are called w/o braces:
Code (glbasic) Select

POKE 1024, 88
REM check left, top corner now
PRINT PEEK(1024)


See also the examples on the Wiki
http://en.wikipedia.org/wiki/BASIC

So, it's not inconsistent, it's BASIC.


bigtunacan

Ok, so if the consistency is that brackets is for return value, and no brackets is no return value, then is there a way for me to create user defined functions that do NOT return values?

Moebius

SUB-routines are essentially that:
Code (glbasic) Select
GOSUB MySub
END

SUB MySub:
     PRINT "...", 0, 0
ENDSUB
Endless Loop: n., see Loop, Endless.
Loop, Endless: n., see Endless Loop.
- Random Shack Data Processing Dictionary

bigtunacan

@Serpent,

No, Sub routines do not accept parameters; it is not at all the same thing as a function that does not return a value.

Kitty Hello

no, that's not possible.

Moebius

... "essentially"...  :whistle:
The only alternative is to ignore the returned number... is that so bad?
Endless Loop: n., see Loop, Endless.
Loop, Endless: n., see Endless Loop.
- Random Shack Data Processing Dictionary

matchy

#27
Errors returned are helpful. Eg:
Code (glbasic) Select

// Hypothetical GLB code
LOCAL out_of_drawbuffer_bounds = DRAWSPRITE(sprite_player, player_x, player_y, check_for_bounds = TRUE)



Ruidesco

Quote from: bigtunacan on 2011-Oct-13
Ok, so if the consistency is that brackets is for return value, and no brackets is no return value, then is there a way for me to create user defined functions that do NOT return values?
Functions do always return a default value when you don't specify any.