Jump to content
IGNORED

Pokey code


Purity

Recommended Posts

Hi guys,

 

I was wondering if you can help me because I am stuck?

 

I am using Prickle to test out Pokey chips in a 7800. Whilst this is great at testing the 4 audio channels it sadly doesn't test the pseudo random number generator or any of the input pins on the chip (pins 8-15)

 

As the source code is available for Prickle I was hoping to add some code to it to add these features, and that's where I am getting stuck

 

I have never programmed in 7800 basic, but as far as I can tell you can use the "prandom" pokey command but I just don't know how. If I could use the prandom command and output the first five numbers from it and display on screen, it would prove if the prandom generator is actually random or not, which I think would be a great test?

 

Also I had a thought about testing the input pins at pins 8-15, but again I would need some code to display a 1 or 0 being the current state of that pin of the chip on screen

 

Any input would be welcome

Edited by Purity
Link to comment
Share on other sites

Random does not require extra pins, the number is placed onto the data bus, 8 through 15 are not connected.

 

Yes I intend connecting pins 8-15 to a resistor array and dip switch so I can test the pot inputs, but I would need to see some status change on the 7800 side, so was wondering if it would be possible to code something to see what the output of those pins were - either 1 or 0 on screen, if that makes sense?

 

Is there any sample .bas code for using the prandom function of the pokey

Link to comment
Share on other sites

  • 3 weeks later...

I've used the code here which is in 6502 assembly:

 

http://7800.8bitdev.org/index.php/Detecting_POKEY

 

Now I can compile it in on online 6502 compiler, and it doesn't give me any errors. The modifications I made are below:


pokel = $00
pokeh = $01
poked = $03
pbase = $04

PAUDF0 = $0
PAUDC0 = $1
PAUDF1 = $2
PAUDC1 = $3
PAUDF2 = $4
PAUDC2 = $5
PAUDF3 = $6
PAUDC3 = $7
PAUDCTL = $8
PRAND = $A
PSKCTL = $F

detpl
       
         lda #%00010000
         sta $470
         ldx #1
detplo
         lda PCHEKL,x
         sta pokel
         lda PCHEKH,x
         sta pokeh
         jsr chekfp
         lda poked
         beq fpchip
         dex
         bpl detplo
fpchip
         sta poked
         rts

pchekl
        .byte $00,$50
pchekh
        .byte $40,$04

chekfp
         ldy #$0f
         lda #$00
         sta poked
rpregl
         sta (pbase),y
         dey
         bpl rpregl

         ldy #PAUDCTL
         sta (pbase),y
         ldy #PSKCTL
         sta (pbase),y

       
         nop
         nop
         nop

         ldy #PRAND
         lda (pbase),y
         cmp #$ff
         bne npoked


         ldy #PSKCTL
         lda #3
         sta (pbase),y
         ldy #PAUDCTL
         lda #0
         sta (pbase),y

         nop
         nop
         nop

         ldy #PRAND
         lda (pbase),y
         cmp #$ff
         beq chekpm
         rts

chekpm
         lda (pbase),y
         cmp #$ff
         beq npoked
         rts

npoked
         dec poked
         rts

Now I'm trying to add this into the Prickle 7800 basic progam using an inline command, I get the following error:

 

C:\7800basic.0.5beta20170212\prickle>c:\7800basic.0.5beta20170212\7800bas.bat "prickle - Copy.bas"
7800basic 0.4 Feb 12 2017 22:54:38

*** (): INFO, GFX Block #0 starts @ $E000
arcadealmostascii
*** (): INFO, GFX block #0 has 1064 bytes left (133 x 8 bytes)


7800basic compilation complete.
User-defined 7800.asm found in current directory
--- Unresolved Symbol List
PCHEKL 0000 ???? (R )
PCHEKH 0000 ???? (R )
ROM8k 0000 ???? (R )
0.topscreenroutine 0000 ???? (R )

12284 bytes of ROM space left in the main area.
pokeysound assembly: 303 bytes
$1880 to $1fff used as zone memory, allowing 12 display objects per zone.
2074 bytes left in the 7800basic reserved area.


Fatal assembly error: Source is not resolvable.
Cartridge data file must be at least 4K!

7800header 0.7 Feb 12 2017 22:54:39
*** WARNING: The file size of C:\7800basic.0.5beta20170212\prickle\prickle - Copy.bas.bin isn't correct.

opened parameter file a78info.cfg

 

Can anyone tell me where I am going wrong please?

Link to comment
Share on other sites

dasm labels are case sensitive, so "PCHEKL" isn't the same thing as "pcheckl". You need to make your labels consistent with your references.

 

This bit of the assembly error output points the way:

 

--- Unresolved Symbol List
PCHEKL                   0000 ????         (R )
PCHEKH                   0000 ????         (R )
ROM8k                    0000 ????         (R )
0.topscreenroutine       0000 ????         (R )

The ROM8k and 0.topscreenroutine are 7800basic symbols that would have eventually either have been defined or ignored, if DASM didn't have trouble find 2 labels/symbols named PCHECKL and PCHECKH.

 

Also, the pokey detection code you're including is already a part of 7800basic. I adapted it for non-basic assembly usage when I wrote that wiki entry. :D

Link to comment
Share on other sites

Also, the pokey detection code you're including is already a part of 7800basic. I adapted it for non-basic assembly usage when I wrote that wiki entry. :D

 

Well that's awesome fella. I won't bugger about with this anymore then :-)

 

I assume I can call the 7800basic version in a similar way using the inline option? Or is there another way to include that detection method in a basic program? What I'm trying to do is test out the random number part of the Pokey, and this code seems to do that, but stick the code at the beginning of the Prickle code

Link to comment
Share on other sites

Well that's awesome fella. I won't bugger about with this anymore then :-)

 

I assume I can call the 7800basic version in a similar way using the inline option? Or is there another way to include that detection method in a basic program? What I'm trying to do is test out the random number part of the Pokey, and this code seems to do that, but stick the code at the beginning of the Prickle code

The 7800basic version of this code gets automatically called when the 7800 runs the cart, so long as there's a "set pokeysound on" line at the top of the 7800basic program.

 

It does use the POKEY random numbers to detect if the chip is present. So if pokey is actually detected in 7800basic, the random number generator has been tested.

Link to comment
Share on other sites

There seems to be a bug somewhere with this

 

As previously said I can see that the Prickle code uses the "set pokeysupport on".

 

and there is a line in the code which says

 

"if !pokeydetected then goto nopokeyfound"

 

The nopokeyfound sub displays text that says it cannot find the Pokey, as you would expect

 

I have tried this on real hardware with no Pokey plugged in, and it says it still finds it at $4000 ???

 

Surely it should be going to that sub because the random number test should have failed at the if !pokeydetected line?

Edited by Purity
Link to comment
Share on other sites

Hmmm, the code emulates fine - when pokey is disabled, it doesn't find one. I'm thinking the false positive on real hardware might be the result of the floating bus at $4000 returning randomish values. I'll see if I can figure out a work around.

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...