It is currently Thu Dec 14, 2017 8:22 am

All times are UTC - 7 hours



Forum rules


Related:



Post new topic Reply to topic  [ 33 posts ]  Go to page 1, 2, 3  Next
Author Message
PostPosted: Wed Apr 26, 2017 1:09 am 
Offline

Joined: Mon Nov 14, 2016 3:12 pm
Posts: 20
Location: France
Hello,

I own a SUPER NES EMULATOR SE with Assembler, Linker and Debugger.

I modified a public code for assemble and link it. After assemble it without error, I found 2 issues when run it:

First : $4212 register never return $01 but $?2. How is possible to return 2 value when only bit 0, 6 an 7 can be set?

Second : When I CMP with $02 value in VBlank, only the first two conditions works (Red and Yellow BEQ) but not all others.

Please, look at the screenshot attachment. I can provide the ISX file is needed. Thanks for your help!

Here is the main file code :

Code:
; bgcolor
; Press the A, B, X and Y buttons to change the background color.

   file head.s
   file reg.s
   file set.s
   file val.s
   file init.s

bank0 group 0

   org $8000

Reset:

   Reset

Main:

    ; Set accumulator register to 8-bit
    sep #$20

    ; Set color 0 of palette 0 to white
    stz CGADD
    lda #$FF
    sta CGDATA
    lda #$7F
    sta CGDATA

    ; Enable the screen at full brightness
    lda #$0F
    sta INIDISP

    ; Enable VBlank and the joypad
    lda #(NMITIMEN_NMI_ENABLE | NMITIMEN_JOY_ENABLE)
    sta NMITIMEN

    ; Keep waiting for interrupts
w00 wai
    jmp w00

VBlank:
    ; Wait until the joypad input can be read
    lda #HVBJOY_JOYREADY
w01 and HVBJOY
    cmp #HVBJOY_JOYREADY
    bne w01

    ; Prepare to change color 0 of palette 0
    stz CGADD

    ; Reset accumulator register to 16-bit
    rep #$20
   
    on16a
   
    ; Jump to label Yellow if the A and Y buttons were pressed
    lda #(JOY_RED + JOY_GREEN)
    and JOY1
    cmp #(JOY_RED + JOY_GREEN)
    beq Yellow

    ; Jump to label Red if the A button was pressed
    lda #JOY_RED
    and JOY1
    cmp #JOY_RED
    beq Red

    ; Jump to label Yellow if the B button was pressed
    lda #JOY_YELLOW
    and JOY1
    cmp #JOY_YELLOW
    beq Yellow

    ; Jump to label Blue if the X button was pressed
    lda #JOY_BLUE
    and JOY1
    cmp #JOY_BLUE
    beq Blue

    ; Jump to label Green if the Y button was pressed
    lda #JOY_GREEN
    and JOY1
    cmp #JOY_GREEN
    beq Green

    lda #RDNMI
   
    off16a

    rti

Red:
    ; Set accumulator register back to 8-bit
    sep #$20
   
    ; Set color 0 of palette 0 to red
    lda #%00011111
    sta CGDATA
    lda #%00000000
    sta CGDATA

    rti

Green:
    ; Set accumulator register back to 8-bit
    sep #$20

    ; Set color 0 of palette 0 to green
    lda #%11100000
    sta CGDATA
    lda #%00000011
    sta CGDATA

    rti

Blue:
    ; Set accumulator register back to 8-bit
    sep #$20

    ; Set color 0 of palette 0 to blue
    lda #%00000000
    sta CGDATA
    lda #%01111100
    sta CGDATA

    rti

Yellow:
    ; Set accumulator register back to 8-bit
    sep #$20

    ; Set color 0 of palette 0 to yellow
    lda #%11111111
    sta CGDATA
    lda #%00000011
    sta CGDATA

    rti

EmptyHandler:

    rti
   
    end


Attachments:
File comment: Screenshot
000_0010.JPG
000_0010.JPG [ 829.75 KiB | Viewed 1642 times ]


Last edited by Peperocket on Wed Apr 26, 2017 6:07 am, edited 1 time in total.
Top
 Profile  
 
PostPosted: Wed Apr 26, 2017 5:39 am 
Offline

Joined: Thu May 15, 2008 4:05 am
Posts: 25
Can you post the rom ? Might be easier to analyze ...

Also great to see that some owner of the SE devkit are really using it ! <3

_________________
https://twitter.com/Lint_
http://snesdev.antihero.org/ [depecated blog, new one coming one of these days]


Top
 Profile  
 
PostPosted: Wed Apr 26, 2017 5:51 am 
Offline

Joined: Mon Nov 14, 2016 3:12 pm
Posts: 20
Location: France
Thank you for answer.

Pseudo Instruction ON16A/ON16OFF notified the assembler that the effective data range is being processed in 16 bits.

I've attached the source and ISX files. Don't know if ISX is readed by other emulator however.

ISX is the output file from ISLK (linker) and include symbol value and data area definition table for debugger.


Attachments:
File comment: Source and ISX file
20170426.zip [6.26 KiB]
Downloaded 43 times
Top
 Profile  
 
PostPosted: Wed Apr 26, 2017 7:38 am 
Offline

Joined: Thu May 15, 2008 4:05 am
Posts: 25
Is there a way to ouput something else than .isx format ?

_________________
https://twitter.com/Lint_
http://snesdev.antihero.org/ [depecated blog, new one coming one of these days]


Top
 Profile  
 
PostPosted: Wed Apr 26, 2017 7:58 am 
Offline

Joined: Mon Nov 14, 2016 3:12 pm
Posts: 20
Location: France
I found an ISX to ROM converter and apply to ISX file but ROM doesn't seem to work on my Everdrive flash card.

http://www.inetmie.or.jp/~koh/inside/koh-tool.htm

I attached the converted rom, I hope it could help.


Attachments:
File comment: Converted ROM from ISX file
PROG.ROM [32 KiB]
Downloaded 45 times
Top
 Profile  
 
PostPosted: Wed Apr 26, 2017 8:26 am 
Offline

Joined: Thu May 15, 2008 4:05 am
Posts: 25
in your code you have :

Quote:
VBlank:
; Wait until the joypad input can be read
lda #HVBJOY_JOYREADY
w01 and HVBJOY
cmp #HVBJOY_JOYREADY
bne w01

Could you try to change that to :
Quote:
VBlank:
; Wait until the joypad input can be read
lda HVBJOY
w01 and #HVBJOY_JOYREADY
cmp #HVBJOY_JOYREADY
bne w01

and change
Quote:
HVBJOY_JOYREADY def $82

to
Quote:
HVBJOY_JOYREADY def $81

wich is the right value.

I really suspect that the "and $4212" is not the correct way to check for value.

_________________
https://twitter.com/Lint_
http://snesdev.antihero.org/ [depecated blog, new one coming one of these days]


Top
 Profile  
 
PostPosted: Wed Apr 26, 2017 9:05 am 
Offline

Joined: Mon Nov 14, 2016 3:12 pm
Posts: 20
Location: France
Thank you for your help.

The initial HVBJOY_JOYREADY value was $01 but as you can see on screenshot, my $4212 register always return $?2 values ($C2, $82, $02, etc ...).

After making the change for check the value code, I got the same issue (only the two first colors (yellow and red) are display when I push joypad buttons, others don't work)

When I change the $81 value too for HVBJOY_JOYREADY, nothing is happend when I push joypad buttons.


Top
 Profile  
 
PostPosted: Wed Apr 26, 2017 10:59 am 
Offline

Joined: Sun Mar 27, 2016 7:56 pm
Posts: 138
Hang on, you have the software for the Emulator SE? Last I heard, people haven't been able to find that anywhere; is there a chance you could upload it somewhere?


Top
 Profile  
 
PostPosted: Wed Apr 26, 2017 11:03 am 
Offline

Joined: Sun Apr 13, 2008 11:12 am
Posts: 6520
Location: Seattle
Peperocket wrote:
The initial HVBJOY_JOYREADY value was $01 but as you can see on screenshot, my $4212 register always return $?2 values ($C2, $82, $02, etc ...).
Odds are good that the middle five bits are not explicitly driven, and that "2" is set because the last byte on the data bus was the $42. (And the other four bits are low for the same reason)

So, while you're ≈right that you should mask the result you loaded, that should look like "and #$c1" to get rid of the bits that aren't explicitly driven.

Actually, really, you should mask and compare only the bits that you care about. You don't care about hsync/vsync in this case, so why are you keeping them at all? Use the BIT instruction.


Top
 Profile  
 
PostPosted: Wed Apr 26, 2017 11:21 am 
Offline

Joined: Mon Nov 14, 2016 3:12 pm
Posts: 20
Location: France
Nicole wrote:
Last I heard, people haven't been able to find that anywhere


Maybe they don't know the VUE Debugger software (Virtual Boy) hold SHVC/SNES abilities.

You can find here : http://www.planetvb.com/modules/hardware/?type=vue

Use the japanese VUE Developement Software version for Intelligent System SHVC Debugger and US version for SNES Emulator SE.

I can provide the Assembler/Linker/Debugger english version manual if needed.


Top
 Profile  
 
PostPosted: Wed Apr 26, 2017 11:23 am 
Offline

Joined: Sun Apr 13, 2008 11:12 am
Posts: 6520
Location: Seattle
Also, warning, from my own experience:

vblank NMI has enough time to start executing code before autoread starts, so you can't just wait for vblank, then wait for autoread to end.


Top
 Profile  
 
PostPosted: Wed Apr 26, 2017 2:12 pm 
Offline

Joined: Mon Nov 14, 2016 3:12 pm
Posts: 20
Location: France
Hello,

Thank you for your answer. I don't really understood what you mean when you're talking about "VBlank has enought time to start executing code before autoread start" because only thing I need to do in VBlank is reading joypad register and I can do only at the autoread start.

Do you think my VBlank handler is not reliable?


Top
 Profile  
 
PostPosted: Wed Apr 26, 2017 2:51 pm 
Offline

Joined: Sun Mar 27, 2016 7:56 pm
Posts: 138
What they mean is, autoreading doesn't start until a little bit after vblank, so HVBJOY can show up as "ready" from the previous frame before it becomes "not ready". It's better to wait for it to not be ready, and then wait for it to be ready, to make sure you don't end up reading it before autoreading happens.


Top
 Profile  
 
PostPosted: Wed Apr 26, 2017 3:32 pm 
Offline

Joined: Sun Apr 13, 2008 11:12 am
Posts: 6520
Location: Seattle
Exactly.

Per anomie's documentation, there's 32-97 pixels after NMI before [$4212]&1 reads as 0. That's 128-388 master cycles, 13-64 instruction cycles, or enough time after the NMI starts for 1-20 instructions to execute.

So ... make sure you do something else in your NMI before you check HVBJOY. Doesn't have to be much. If you're not using an NMI (as I wasn't), wait for autoread to start and finish, instead of waiting for Vblank to start.


Top
 Profile  
 
PostPosted: Fri Apr 28, 2017 8:42 am 
Offline

Joined: Mon Nov 14, 2016 3:12 pm
Posts: 20
Location: France
Hello,

Thank you all for explanation. I have re-written the Joypad routine and NMI's one but at this time, the program is a little bit buggy since the left direction doesn't show anything and the right one show blue screen (it must be yellow). I don't really understand ... Could you help me please?

Code:
; ***********************************************************
; *** Bgcolor 20170428 V0.1                        ***       
; *** Press the U, D, L, R buttons to change the          ***
; *** background color.                               ***
; ***********************************************************

   file head.s
   file reg.s
   file set.s
   file val.s
   file init.s

bank0 group 0

   org $8000

Reset:
   Reset

Main:
    ; Set accumulator register to 8-bit
    sep #$20

    ; Set color 0 of palette 0 to white
    stz CGADD
    lda #$FF
    sta CGDATA
    lda #$7F
    sta CGDATA

    ; Enable the screen at full brightness
    lda #$0F
    sta INIDISP

    ; Enable VBlank and the joypad
    lda #(NMITIMEN_NMI_ENABLE | NMITIMEN_JOY_ENABLE)
    sta NMITIMEN

   
; ***********************************************************
; ***  Main Code                                 ***       
; ***                                          ***
; ***                                            ***
; ***********************************************************
                 
MainLoop:
   wai
   
   lda JoypadLo               ; Put pad register copied in Direct Page into Accumulator
   
   ; Prepare to change color 0 of palette 0
    stz CGADD
   
Up:
   bit #JOYH_UP               
   beq Down                  
   
    ; Set color 0 of palette 0 to red
    lda #%00011111
    sta CGDATA
    lda #%00000000
    sta CGDATA
   
Down:
   bit #JOYH_DOWN               
   beq Left                  
   
    ; Set color 0 of palette 0 to green
    lda #%11100000
    sta CGDATA
    lda #%00000011
    sta CGDATA

Left:
   bit JOYH_LEFT               
   beq Right                  

    ; Set color 0 of palette 0 to blue
    lda #%00000000
    sta CGDATA
    lda #%01111100
    sta CGDATA

Right:
   bit JOYH_RIGHT               
   beq TerminateControl   

    ; Set color 0 of palette 0 to yellow
    lda #%11111111
    sta CGDATA
    lda #%00000011
    sta CGDATA

TerminateControl:    
   bra MainLoop               

   
; ***********************************************************
; *** NMI Interrupt                              ***
; ***                                            ***
; ***********************************************************

NMI:
    php
   pha
   phx
   
w00:
   lda HVBJOY                  ; status register, bit 0 joypad ready?
   and #$00         
   bne w00
   
w01:
   lda HVBJOY                  ; status register, bit 0 joypad ready?
   and #$01         
   bne w01

   lda JOY1H                   ; on stock le registre $4219 (status register) dans A (bystudlr)     
   sta JoypadLo               ; pour le copier en page 0
   
   lda #RDNMI                  ; clear NMI flag
   
   plx
   pla
   plp
   
   rti

EmptyHandler:
    rti
   
    end




Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 33 posts ]  Go to page 1, 2, 3  Next

All times are UTC - 7 hours


Who is online

Users browsing this forum: ReverendSA and 11 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group