GoSub for Oric

Everything related to BASIC version 1.x (Oric 1 and Atmos) or HYPERBASIC (Telestrat).
Don't hesitate to give your small program samples, technical insights, or questions...
Post Reply
Chris
2nd Star Corporal
Posts: 29
Joined: Tue Jun 05, 2007 1:45 am
Location: Oregon, United States
Contact:

GoSub for Oric

Post by Chris » Mon Aug 25, 2008 5:53 am

Control the submarine "=" by the arrow keys while avoiding the octopus "M" and the walls "-". Download the first version http://www.atari2600land.com/oric/gosuboric.tap. And a quick question: How big in Ks can an Oric tape be? Because I was going to design several more levels than just this one that repeats over and over again.

User avatar
Dbug
Site Admin
Posts: 2366
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Post by Dbug » Mon Aug 25, 2008 7:12 pm

Depends if you are using TEXT or HIRES mode.

If you are using TEXT, you can disable the HIRES mode entirelly at the start of the program by using the command GRAB, which will give you 7 more kilobytes available for the program :)

In HIRES you have 37631 bytes available for the BASIC (including code and variables, so the TAP file can't be that large), in TEXT you have about 44000 bytes.

Chris
2nd Star Corporal
Posts: 29
Joined: Tue Jun 05, 2007 1:45 am
Location: Oregon, United States
Contact:

Post by Chris » Mon Aug 25, 2008 9:20 pm

So all I have to do is type

Code: Select all

1 GRAB
at the beginning of the program for 7 more Kilobytes?

User avatar
Dbug
Site Admin
Posts: 2366
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Post by Dbug » Mon Aug 25, 2008 9:25 pm

Yup.
It does not have to be at the begining, but it has to be executed before any variable is initialised, because it will reset the variable area memory.

Chris
2nd Star Corporal
Posts: 29
Joined: Tue Jun 05, 2007 1:45 am
Location: Oregon, United States
Contact:

Post by Chris » Mon Aug 25, 2008 11:25 pm

Cool! Thanks for mentioning that
Here are some pictures from the updated version.
Image
Image
The link in the first post will always be the latest version.

User avatar
Dbug
Site Admin
Posts: 2366
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Post by Dbug » Wed Aug 27, 2008 9:20 pm

By POKING in the area #B400 to #B800 you can easily redefine the characters to look better.

If you want to fill the character A (ASCII code 65) as a square pattern, you can just do that way:

Code: Select all

POKE #B400+(8*65)+0,1+2+4+8+16+32
POKE #B400+(8*65)+1,1+32
POKE #B400+(8*65)+2,1+32
POKE #B400+(8*65)+3,1+32
POKE #B400+(8*65)+4,1+32
POKE #B400+(8*65)+5,1+32
POKE #B400+(8*65)+6,1+32
POKE #B400+(8*65)+7,1+2+4+8+16+32
(Admitelly, you want to do that using DATA/READ, not by POKEing one by one).

Would make the game a lot more attracting visually speaking !

Some other neat trick, is to write some of the characters on screen using the video inverse. Doing that you can easly have four colors on screen, two for the background/landscape, and two others for the players or sprites.

To do inverse video, you just need to add 128 to the code of the caracter you are displaying:

Code: Select all

POKE #BB80+(Y*40)+X,65  <- Display a normal A
POKE #BB80+(Y*40)+X,65+128  <- Display an inverted A
Good luck :)

Chris
2nd Star Corporal
Posts: 29
Joined: Tue Jun 05, 2007 1:45 am
Location: Oregon, United States
Contact:

Post by Chris » Fri Aug 29, 2008 4:43 am

Dbug wrote:By POKING in the area #B400 to #B800 you can easily redefine the characters to look better.

If you want to fill the character A (ASCII code 65) as a square pattern, you can just do that way:

Code: Select all

POKE #B400+(8*65)+0,1+2+4+8+16+32
POKE #B400+(8*65)+1,1+32
POKE #B400+(8*65)+2,1+32
POKE #B400+(8*65)+3,1+32
POKE #B400+(8*65)+4,1+32
POKE #B400+(8*65)+5,1+32
POKE #B400+(8*65)+6,1+32
POKE #B400+(8*65)+7,1+2+4+8+16+32
(Admitelly, you want to do that using DATA/READ, not by POKEing one by one).
Is that code just for the letter A or does it apply to all the letters? I don't know much about POKE, though, what does it do?

User avatar
waskol
Flight Lieutenant
Posts: 331
Joined: Wed Jun 13, 2007 8:20 pm
Location: FRANCE, Paris

Post by waskol » Fri Aug 29, 2008 10:10 am

This is just for letter A on account of the (8*65)

If you want to do the same for letter B, it will be :

Code: Select all

POKE #B400+(8*66)+0, 1+32
...
POKE #B400+(8*66)+7, 1+32
What you have to know about your oric memory, is that it is a bunch of 8-bits boxes numbered from 0 to 65535 (In other words, in hexadecimal, it is numbered from #0000 to #FFFF). Those numbers are called addresses : just think about letter boxes in a street, numbered for the post officers.

The principle is that you should be able to retrieve or modifie any of those 65535 values.
In BASIC, there is a direct method wich is the use of POKE and PEEK (and also DEEK and DOKE).

If you want to retrieve a value :
value=PEEK(address)

If you want to change a value :
POKE address,value

Now, in you Oric memory, there are some set of boxes that contain your programs, some other nothing, some other some well known values (for instance, some squares represent the screen, some other the graphics of each caracter)

Starting at address #B400, you will find all the graphics of letters, numbers and special symbols.
For each letter, number or symbol, the graphics are defined with 8 lines of 6 pixels wide, in memory it means that each letter is coded with 8 contigous bytes (1 byte=8 bits=(6 usefull pixels+2 bits never used), 8 bytes=8 lines).

Starting from #B400, the graphics are also ordered in the ASCII value order, starting from caracter wich has the 0 ASCII value and finishing with graphics for the caracter wich has the ASCII value 127.

So for letter 'A', the address of graphics will start at #B400+(8*65) , 65 is the ASCII value of A, and will finish at address #B400+(8*65)+7.

It means that if you "POKE" at address #B400+(8*65), you change the graphics of letter A.
For B, graphics will start at address #B400+(8*66) , and will finish at address #B400+(8*66)+7.

The general formula to get the address of the graphics will start at :
#B400+(8*ASCII_VALUE)+0

More generally, we use some data statements, a loop, and a POKE in order to modify graphics :

Code: Select all

5 REM Som graphics for a Space Invaders game
10 V1=ASC('A')
20 V2=ASC('C')
30 FOR I=V1 TO V2
40    FOR J=0 TO 7
50      READ(L):POKE #B400+(8*I)+J
60    NEXT J
70 NEXT I
95 REM Graphics for letter A
100 DATA 8,8,28,42,42,42,8,0
105 REM Graphics for letter B
110 DATA 28,62,28,8,20,42,42,0
115 REM Graphics for letter A
120 DATA 34,54,42,62,8,20,34,0
150 PRINT "A B C "
Exercise :
Find in your manual, what contains the so specific addres #26A
Before doing it, try to guess, then what will do :

Code: Select all

POKE #26A,10
Try it then !
It is very often used for games ;)

Chris
2nd Star Corporal
Posts: 29
Joined: Tue Jun 05, 2007 1:45 am
Location: Oregon, United States
Contact:

Post by Chris » Fri Aug 29, 2008 9:20 pm

Thank you for the information. This looks a lot better.
Image

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests