Jump to content
IGNORED

is SEI enough to disable DLI for a moment?


Marius

Recommended Posts

Hi!

 

I have this issue:

 

I need to hack a program but I do not have the sourcefiles. The game is "The Brundles" and this game occupies ram that is usually used by the OS. Using PORTB settings the ROM area is turned into ram. OK cool.

 

But during the game I need to enable the OS for a short while, because I want to be able to do a FLIP DISK on MyIDE. Since these Flip Disk routines are in the MyIDE OS ROM it is impossible to establish this with the ROM disabled.

 

So far so good... I found everything I need, and I think my routines are ok too. But it still fails.

 

I found out that there is a DLI running on C196 ... and ofcourse, as soon as I turn 'on' the os the atari crashes. This makes sense. So I thought I use the SEI instruction to prevent this, but the Atari still crashes.

 

The Brundles is looping in a 'check fire button routine' so that makes it easy: that's the moment where I want to switch on the OS for a while. This 'check fire button' is not in the DLI, but in the mainloop (good news again). As soon as the firebutton is pressed, the Brundles leaves this 'check for fire button' routine, so that is where my second routine comes in to disable the os again. This second routine works perfect. The first routine makes the program crash.

 

Here is my routine:

Routine 1

SEI
LDA #$FF ; switch built in OS on
STA PORTB
JMP back to check firebutton routine

Routine 2
LDA #$ FE ; switch OS off again
STA PORTB
LDA #$00    ; this is regular code from the game
STA NMIEN ; this is regular code from the game
STA IRQEN ; this is regular code from the game
STA DMACTL ; this is regular code from the game
CLI ; I thought this is a good idea to reenable any running interrupts again
JMP back to the game. 

 

Although I was concentrating all the time on Routine 2; I found out this routine works, and is NOT the issue. The problem is that routine 1 makes the game crash. Obviously SEI is not enough to disable running Interrupts?!? Somewhere I read that it might be needed to creat a very short pause afer the SEI command, but I think this is nonsense (anyone can affirm it?)

 

I have checked what the value of PORT B is in this game: it is #$FE; so using LDA #$FF and #$FE is ok (I do not need to phush the value on the stack, and I do not need logical operations to enable/disable bit zero of PORTB)

 

The weirdest is that the game is doing nothing more than a short check firebutton loop. It's amazing that it still crashes after

 

SEI

LDA #$FF

STA PORTB

 

So any help would be appreciated.

 

I hacked 'the Brundles' also in another way; that was an easy job... making the game loading the levels from D2: in stead of D1: made it possible to run the games from the Partitions in MyIDE. But since these are limited to not more then 14 partitions, I'm not going to give up 2 (or 3) of them just for one game ;) ... so that's why I decided to hack the game further to make it run from the images on MyIDE.

Link to comment
Share on other sites

SEI disables only IRQ interrupts. DLI is an NMI interupt, which can be disabled by writing to $D40E. Bit 7 enables/disables DLI and bit 6 VBI. So if disabling DLI is enough, write $40 to $D40E and after flip disk you can reenable it by writing $C0.

Link to comment
Share on other sites

@Mapa Ah thanks!

 

That is probably the reason why the whole thing crashed.

 

After I posted this topic I realised: when I disable (all) IRQ's I probably can not use the flip disk feature in MyIDE BIOS, since that is keyboard-driven. Will SEI disable the Keyboard IRQ? If yes: is there a way I can switch that back on?

 

Another solution would be (in case I can not use the keyboard) I enter a JSR -> flipdisk routine in MyBIOS which will take care of the flipdisk.

 

First I am going to try what you suggested. thanks a lot!

M.

Link to comment
Share on other sites

The other thing is that SEI will only temporarily mask an IRQ. If there's one pending it'll fire off once you CLI.

Best method is to early on disable any interrupts that you don't want occurring.

 

For IRQs from Pokey that means modifying both POKMSK ($10) and the IRQEN register ($D20E). The PIA IRQs are normally disabled by default and most software doesn't bother setting the PIA bits that control them.

 

For simple keyboard stuff, you can disable the IRQ and read the keyboard register manually as well as the key up/down state flag. But you should also do your own debounce etc. The beauty of the OS key IRQ and VBlank Stage 2 is that it will take care of all that for you and you only need read the CH ($2FC) shadow then set to $FF when accepted a key.

 

If only temporarily disabling IRQ e.g. to switch the OS out briefly then you can usually just use the SEI/CLI sequence.

Link to comment
Share on other sites

Ah thanks for all the help.

 

It's quick and dirty now, but it works.

 

I can load my 'hacked' Brundles disk 1 from the images. Then when the game usually asks for level disk (which is a nice and colorful screen with DLI's) now you see a dirty screen full of garbage sh*t. But ok... when I can switch the Shift + Control 2 keycombi that is needed to flip disks on MyBIOS and then I can continue and indeed, then it works!

 

So now I'm going to search for free memory to create a replacement screen what looks nice (and no garbage) that asks for Level disk.

 

Thanks for the help. The important stuff works now!

 

Great game this Brundles btw.

Link to comment
Share on other sites

Great!

 

I succeeded.

 

Thanks for all your help guys. Attached The Brundles. This one will run from MyIDE (as long as you have a MyBIOS in ROM; not flash)

 

IMPORTANT:

This only works in 64KB settings. I did not alter the other routines to load it into highmem.

If you already altered settings, boot the first disk with space pressed. Chose 0KB then!

Edited by ProWizard
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...