Ultimate Amiga

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: Read/Write HEX  (Read 6109 times)

0 Members and 1 Guest are viewing this topic.

BooBoo

  • Amiga Guru
  • A600
  • ****
  • Karma: 3
  • Offline Offline
  • Posts: 168
Read/Write HEX
« on: January 03, 2009, 03:02:23 PM »

Hi id like to be able to read and write HEX
With thanks to HH heres what I have so far
Code: [Select]
A=0
Reserve As Work 2,2000
LOCATIONVARIABLE=Start(2)
Bload "Temp:Blank.DAT",2
OFFSET=$20
Input A
Poke LOCATIONVARIABLE+A+OFFSET,$23
Bsave "Temp:blank.dat",Start(2) To Start(2)+Length(2)

So this will write "23" to the location you enter

So id like to be able to read it back so if the first byte is "00" Print "A" and if its "23" Print "B"

Any help will be appreciated :)


Logged

Hungry Horace

  • Amorphous Blue-Blob Man
  • Site Admin
  • A4000T
  • ******
  • Karma: 307
  • Offline Offline
  • Gender: Male
  • Posts: 3,364
  • Don't forget... Ameboid's need love too!
    • AUW
Re: Read/Write HEX
« Reply #1 on: January 03, 2009, 03:26:17 PM »

this would follow on, and allow you to read not only the next value, but as many consecutive bytes as you want to.

You just need to "PEEK" to get your value back, and do some testing with IF/ELSE/ENDIF statements.

Code: [Select]
FOR N=0 to $20 : REM -- for as many bytes as you want to read. (set N=0 to 0 if you just want the one byte, or remove the entire FOR/NEXT loop)

readingcode=PEEK (LOCATIONVARIABLE+A+OFFSET+N) : REM - include any offset you need.

IF readingcode=$00
PRINT "A"
ELSE IF readingcode=$23
PRINT "B"
ELSE
PRINT "something else"
ENDIF

NEXT N
Logged
Quote from: KillerGorilla
because winuae is made of code and your amiga is made of stuff

BooBoo

  • Amiga Guru
  • A600
  • ****
  • Karma: 3
  • Offline Offline
  • Posts: 168
Re: Read/Write HEX
« Reply #2 on: January 03, 2009, 04:54:48 PM »

Thanks again HH yep thats done it I think thats enough for me to get started on a little project im sure ill get stuck again soon ;)
Logged

BooBoo

  • Amiga Guru
  • A600
  • ****
  • Karma: 3
  • Offline Offline
  • Posts: 168
Re: Read/Write HEX
« Reply #3 on: January 04, 2009, 09:50:35 AM »

Hi again - Im using the hex to read game Map data and display the tiles on screen
I hopeing to to display 64 16*16 tiles across but im max at about 57
Is there any way I can increase beyond screen width 1023?
Screen Open 0,1023,200,16,lowers

Logged

Hungry Horace

  • Amorphous Blue-Blob Man
  • Site Admin
  • A4000T
  • ******
  • Karma: 307
  • Offline Offline
  • Gender: Male
  • Posts: 3,364
  • Don't forget... Ameboid's need love too!
    • AUW
Re: Read/Write HEX
« Reply #4 on: January 04, 2009, 12:28:42 PM »

unfortunately, no, 1024 pixels is the maximum.

http://amos.condor.serverpro3.com/AmosProManual/6/601.html

you need to create a screen a couple of blocks larger than the visable area, (probably, 320+32) and have it update the edges (invisible areas) as your display attempts to scroll into them... basically you "reveal" the edge area as you scroll, and as you move along 1 block, the progam updates the edge areas according to your (temporarily) stored map data.

Getting a nice routine going for this can be a tad tricky at first i must admit, although i know there's a good example of it on the "ultimate amos" examples disk, from chapter 5 - (continuous scrolling).

http://amos.condor.serverpro3.com/tp-downloads/UltimateAmos.adf

writing an example here is a bit more tricky as its not something i'm overly familiar with off-by-heart, and i tend to have to look it up myself!
Logged
Quote from: KillerGorilla
because winuae is made of code and your amiga is made of stuff

SamuraiCrow

  • compile-time wierdo
  • Forum Mod
  • A1200
  • *****
  • Karma: 5
  • Offline Offline
  • Gender: Male
  • Posts: 946
  • Compile-time wierdo
Re: Read/Write HEX
« Reply #5 on: January 04, 2009, 05:56:29 PM »

@booboo

Are you scrolling horizontally, vertically, or both?
Logged

BooBoo

  • Amiga Guru
  • A600
  • ****
  • Karma: 3
  • Offline Offline
  • Posts: 168
Re: Read/Write HEX
« Reply #6 on: January 05, 2009, 08:01:59 AM »

Hi HH yes I want to keep the code nice a simple so I guess ill just shrink the tiles.

Just so you know its Chaos Engine CD32 im trying to read file A1Chaos.Cas - it looks like theres now 3 level viewers over at Eab but im just doing this for a bit of fun I dont want to get to serious.
But its just dawned on me how map data could be used in creating games in Amos.

SamuraiCrow
A very basic script that scrolls horizontally but i planning both.
Logged

SamuraiCrow

  • compile-time wierdo
  • Forum Mod
  • A1200
  • *****
  • Karma: 5
  • Offline Offline
  • Gender: Male
  • Posts: 946
  • Compile-time wierdo
Re: Read/Write HEX
« Reply #7 on: January 05, 2009, 03:21:37 PM »

@booboo

The trick to making a scrolling map with unlimited boundaries is as follows:

Make the screen buffer as big as twice the width of the visible area plus 3 tile widths.  Make the height twice the size of the visible area plus 3 tile widths (unless you want to use a custom copper list instead).

The trick is to draw the additional tiles to the right of the screen when scrolling right but also to the left of the visible area.  This way by the time you run out of the right side of the screen buffer you'll have an exact duplicate along the left edge of the buffer also.  The same works for the vertical dimension.

I used the unlimited horizontal scrolling technique for the "Ribbons and Curls" text scroller but it was only one tile high.  It could scroll really fast though.
Logged

BooBoo

  • Amiga Guru
  • A600
  • ****
  • Karma: 3
  • Offline Offline
  • Posts: 168
Re: Read/Write HEX
« Reply #8 on: January 08, 2009, 08:18:42 AM »

Thanks for the tips I will be back as this little project has given me some ideas for makeing a game.

Ok it not much and its not finnished but its been a bit of fun :)
http://eab.abime.net/album.php?albumid=92&pictureid=650
« Last Edit: January 08, 2009, 08:27:03 AM by BooBoo »
Logged
Pages: [1]   Go Up
 

TinyPortal 2.2.2 © 2005-2022