Welcome, Guest. Please login or register.

Author Topic: Mr Beanbag not working with accelerator  (Read 5425 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline Leffmann

  • Full Member
  • ***
  • Join Date: Feb 2011
  • Posts: 119
    • Show all replies
Re: Mr Beanbag not working
« on: January 26, 2012, 12:38:01 PM »
Quote from: Mrs Beanbag;677449
Try booting normally, but running the game from the shell.

I suspect the problem is in my Workbench initialisation code.  I copied it from somewhere and I never really understood it, worked on my setup though :confused:


I also found that pressing the keyboard causes the game to crash, something with the keyboard interrupt or VBR not taken into account maybe, and also your logo in the beginning will just flash briefly on faster CPUs.

If you don't care about tool-types or command line arguments, then the attached file shows how to make programs WB-friendly:
 

Offline Leffmann

  • Full Member
  • ***
  • Join Date: Feb 2011
  • Posts: 119
    • Show all replies
Re: Mr Beanbag not working
« Reply #1 on: January 27, 2012, 04:25:37 PM »
Quote from: Mrs Beanbag;677639
oh and regarding the keyboard handler, I've had terrible difficulty finding any good information about how to read the keyboard properly, I have three Amiga programming books and none of them say anything useful on the subject :confused:

I found this post on EAB though:
http://eab.abime.net/showthread.php?p=791956

I take it that code would suit my needs, I'd need to turn the relevant interrupt back on though I guess?


I'm guessing you pause the AmigaOS and go directly on the hardware in the game, so it's probably easier to poll the keyboard hardware manually:

Code: [Select]
     ; disable keyboard interrupts

      move.b  #%00001000, ciaaicr


poll  btst    #3, ciaaicr
      beq     poll
         
      ; read event
         
      move.b  ciaasdr, d0
         
      ; handshake
         
      bset    #6, ciaacra
      (wait 85us)
      bclr    #6, ciaacra

      (act on keyboard event)
         
      bra     poll


      ; enable keyboard interrupts before exiting to AmigaOS

      move.b  #%10001000, ciaaicr
 

Offline Leffmann

  • Full Member
  • ***
  • Join Date: Feb 2011
  • Posts: 119
    • Show all replies
Re: Mr Beanbag not working
« Reply #2 on: January 27, 2012, 11:30:51 PM »
Quote from: Mrs Beanbag;677770
Oh and sorry to use you as a kind of living coding reference here but could you give me some idea of how to use UnLoadSeg?  I take it this is the right function to use, basically the problem is, Mr Beanbag's executable is compressed in my own format, the decompression header reserves some memory, decompresses the data into it, and then jumps into it.  But that leaves the compressed data still sitting in memory, uselessly.  I want to be able to free it back up since it's not used anymore, but it's part of the executable.

If the compressed data occupies a section of its own then you should be able to unlink that section from the seglist and UnLoadSeg it, but I haven't actually experimented with it.

An executable is scatter-loaded into memory into a seglist, which is a singly linked list where each segment holds each section of your executable. At offset -4 of each segment you have the size of the whole segment in bytes, at 0 you have a BPTR to the next segment, or 0 if it's the last, and at 4 comes the contents of that section. If you unlink the segment with the compressed data and call UnLoadSeg on it then it should be freed correctly.

Have you looked into in-place decompression? AmigaOS supports BSS after any section, so you can have f.ex a 50K file load into the beginning of 100K of allocated space. With some margins you can decompress backwards (or move the data to the end and decompress forwards) and the decompressed data will never catch up so to speak, so any compressed data you write over has already been read in by your decompression code. This is how most compressors for executables work on the Amiga.
« Last Edit: January 27, 2012, 11:33:45 PM by Leffmann »
 

Offline Leffmann

  • Full Member
  • ***
  • Join Date: Feb 2011
  • Posts: 119
    • Show all replies
Re: Mr Beanbag not working
« Reply #3 on: January 28, 2012, 12:17:41 PM »
Been playing with this a bit and to save you from wasting your time I can say it doesn't work reliably. It never crashes, but there's always a leak of 16 bytes when the program quits, hinting that something else could be terribly wrong.