Jump to content
IGNORED

Emulator / Real Hardware Programming


Recommended Posts

I'm seeing some major differences between what a program I have running in Altirra and the same program on an Atari 65XE.

 

I have the emulator set up as a 65XE and at the moment, I don't suspect the emulator to be at fault.

 

I remember that there was a guide on here somewhere that someone wrote up on how to program for real hardware compared to assumptions that may be made when using an emulator. Does anyone know where it is? I can't find it.

 

I've got the option on to randomise memory and that doesn't show the problem, so it's not that. It'll probably be something I've done.

Link to comment
Share on other sites

Run Xex on some emulators will insert the segments to Ram even if Rom exists at the particular address - this doesn't happen on real hardware.

 

Also with run Xex - I don't think RTCLOCK is updated in emulaton to reflect the delay that would occur on real hardware.

SIO related DCB area at $300... not changed (?)

Since loading is by external program, much more tolerant of sensitive areas being overwritten - e.g. where Dos or a loader would reside, z-page locations.

 

Real hardware might reflect what emulation does in a multi-stage program but have problems at a later time.

Examples of multi-load and execute - some demos, game "Ridiculous Reality", probably a good test candidate as each level is a binary segment.

Link to comment
Share on other sites

My favorite is the accidental LDA 0 instead of #0. Memory location 0 is not initialized by the OS, so it will usually contain 0 unless it's been modified since startup... assuming you have standard DRAM chips... and haven't run a loader like MyPicoDOS that uses it....

  • Like 2
Link to comment
Share on other sites

Thanks all. Jac's guide is the one that I was thinking about.

 

My 65XE is standard, no memory changes etc.

 

I am loading the game from a .atr file (which has a .xex inside) and the game uses xbios internally to load files. I'm loading from an SIO2SD. Do they require a certain area of memory to run or are they completely stand-alone?

 

The error that I'm getting is that the 4x4 tiles which I am using are corrupt. They're using $6C00 to $6FFF (for the make-up of tile) and have 64 tiles in total. I suspect that it may be my code, though it works in the emulator. I'm using $BA00 to $BBFF for the map data. Those areas should be fine. SIO2SD ensures that BASIC is switched off (that is right isn't it?).

 

I've done a RAM test on the 65XE and it comes up normal.

 

Without seeing the code, does anything here sound like it could be problematic?

Edited by snicklin
Link to comment
Share on other sites

The other thing with Basic - if you disable it via Option press, the Ram will be cleared and DList + screen @ $9C20.

If you disable it via PORTB setting or rely on bootloader to do it, the Ram contents from $A000-$BFFF might be anything.

 

Plenty of software on Atari assumes it's being loaded into Ram that's initialized with all zeros but it's not guaranteed and can be a source of problems.

Link to comment
Share on other sites

Well, if I hold down option with SIO2SD and XBIOS, I end up getting the contents of the .atr listed to me rather than running XAUTORUN.

 

I've used this code to disable BASIC....

 

portb equ 54017

LDA portb
AND %11111101
STA portb

 

I've not fiddled around with E: yet. Can I ask what this will do for me? (i.e. I know that I should do it, but don't know why)

 

"If you disable it via PORTB setting or rely on bootloader to do it, the Ram contents from $A000-$BFFF might be anything."

This isn't a problem for me as I copy blocks of data into here and don't rely on zeros.

 

Thanks chaps!

Link to comment
Share on other sites

You're enabling BASIC by clearing BIT 1. Try something like this:

ICCOM	= $342
ICBADR	= $344
ICBLEN	= $348
ICAUX1	= $34A
ICAUX2	= $34B
CIOV	= $E456
PORTB   = $D301

	mva #$01 $3f8	; set BASICF
	mva #$C0 $6A	; adjust RAMTOP
	lda portb
	ora #$02
	sta portb

	ldx #0
	lda #$0C
	sta iccom
	jsr ciov
        mwa #EName icbadr
	mva #$0C icaux1
	mva #$00 icaux2
	mva #$03 iccom
	jmp ciov

EName
	.byte 'E:',$9B

Adjusting RAMTOP and then re-opening the editor just puts the screen data where the OS expects it to be with the BASIC ROM disabled. Anyway, it looks like not disabling BASIC might be your problem here.

Edited by flashjazzcat
  • Like 1
Link to comment
Share on other sites

A quick/dirty shortcut to CLOSE an IOCB is to just store a #$FF in ICHID. That tells CIO the IOCB is not in use so you can just OPEN something else with it.

Don't use it though if dealing with files that are update/output to disk, network etc. otherwise you could lose data.

  • Like 1
Link to comment
Share on other sites

Well, if I hold down option with SIO2SD and XBIOS, I end up getting the contents of the .atr listed to me rather than running XAUTORUN.

 

hold down OPTION during powerup not after load&run xB.

Link to comment
Share on other sites

You're enabling BASIC by clearing BIT 1. Try something like this:

ICCOM	= $342
ICBADR	= $344
ICBLEN	= $348
ICAUX1	= $34A
ICAUX2	= $34B
CIOV	= $E456
PORTB   = $D301

	mva #$01 $3f8	; set BASICF
	mva #$C0 $6A	; adjust RAMTOP
	lda portb
	ora #$02
	sta portb

	ldx #0
	lda #$0C
	sta iccom
	jsr ciov
        mwa #EName icbadr
	mva #$0C icaux1
	mva #$00 icaux2
	mva #$03 iccom
	jmp ciov

EName
	.byte 'E:',$9B

Adjusting RAMTOP and then re-opening the editor just puts the screen data where the OS expects it to be with the BASIC ROM disabled. Anyway, it looks like not disabling BASIC might be your problem here.

 

Ahh, must have misread an example with the accidental enabling of BASIC.

 

Erm, my program is using custom display lists which use screen memory at $6000. I'm using memory before and after that for code / data. Could playing around with RAMTOP affect this?

Link to comment
Share on other sites

If you're not actually using the screen editor then you can put it where you like and overwrite the screen RAM with your own data, but it's worth opening it at the start of your program since doing so will close down any VBXE 80 column display DOS might be running (with the S_VBXE driver).

Edited by flashjazzcat
Link to comment
Share on other sites

 

hold down OPTION during powerup not after load&run xB.

 

Aggh, this is the correct answer. I was holding down Option for too long. When I used to load disks as a boy, I always held it down for a while to ensure I didn't get errors.

 

When I hold it down for a short time, the game loads and works correctly. I feel somewhat daft now.

Edited by snicklin
Link to comment
Share on other sites

I don't know what are you programming... but I assume that you use just your code (except of maybe OS VBI) so forget about RAMTOP, E: handler, IOCB, CIO etc. it does not affect your program.

 

It's my "Escape the Night Garden" game (take a look on YouTube if you've not seen it). I'm writing all my own code, yes. Thanks for the tip. Eventhough I now know not to hold down Option for so long, I'll still implement your code for switching off Basic.

Link to comment
Share on other sites

$6000 is way out of reach for interference provided you didn't inadvertantly change RAMTOP to some bad value.

Self-Test Rom maps in at $5000 though, so you need to take care not to inadvertantly enable that.

 

Thanks for the help. No, I've never touched RAMTOP. I've never really understood the reason for it anyway if you're laying out your own memory.

Link to comment
Share on other sites

The reasoning is so the screen handler knows where to stop clearing/moving data.

It's a copy of the OS variable RAMSIZ at $2E4 which holds the highest contiguous Ram page, modifying it allows moving the screen elsewhere without impacting other areas of memory management.

 

The often made mistake is people just bump RAMTOP ($6A) downwards based on what's already there. OK for once off programs like assembler games but not good for ones that can run multiple times like Basic programs - proper practice is base your Ram reservations on RAMSIZ (but only modify RAMTOP).

Link to comment
Share on other sites

Yes: going through the motions in the proper way using a few bytes of code does no harm and avoids unexpected glitches. As I wrote earlier, opening E: is the only driver-friendly way to be sure that any 80 column VBXE display is shut down before you set up your display. This may only prove to be an issue 0.001 per cent of the time, but it will eventually happen if your program can be started from the SDX command line (regardless of where you point the DL vector). In addition, should you allow for an exit to DOS (perhaps unlikely in a game), you should tidy up RAMTOP and open the editor before jumping through DOSVEC unless you want a lot of crap all over the screen.

Link to comment
Share on other sites

Hmmm,

 

maybe you can add 57 Bytes to your code, so Basic gets disabled automatically ?!?

Here is a Basic-off switch by Bill Wilkinson (appeared in Compute! magazine). It uses page 4 to switch off Atari Basic, but after that, page 4 is fully available again and can be used for other code...

 

I have added this small tool to all my ML-files that do not require Atari Basic. If you don`t want to code a Basic off switch yourself, simply use this one from Bill...

 

 

BASOFF.XEX

Link to comment
Share on other sites

If you don't mind the screen not being reopened or PortB being hit without consideration to what current banking state is, you could do a Basic off real cheaply.

 

Segment to set PortB:

01,D3,01,D3,FF

 

Optional segment to make change persistent over warmstarts:

F8,03,F8,03,FF

 

Optional segments to set RAMTOP and RAMSIZ:

6A,00,6A,00,C0

E4,02,E4,02,C0

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...