Page 7 of 10

Re: quest

Posted: Wed Mar 08, 2006 1:26 pm
by Memblers
lord_Chile wrote: example: super mario bros 3 [PRG0], super mario bros 3 [PRG1]?????

what is difference??
It's a revision, the differences could be anything (bug fixes, or any other changes). I know Tecmo Bowl had a revision to change a player in the game, and Castlevania had one that changed at least one of the levels.

Posted: Wed Mar 08, 2006 2:37 pm
by Dwedit
Super Mario 3 fixed a typo, and changed the names of the worlds in the ending. During the ending, the prg0 version displays the same names as the Japanese version, while the prg1 version uses the names found in the US instruction manual. So instead of "Ocean Side", "Big Island" and "Pipe Maze", they are called "Water Land", "Giant Land" and "Pipe Land".

question about nsf

Posted: Thu Mar 09, 2006 5:30 am
by lord_Chile
Bregalad wrote: Play an nsf would be nothing more complicated than this :

Code: Select all

PlayNMI
   jsr Init
*: jmp *

NMI
   jsr Play
   rti
You mean:

i will load from knowed address in nsf 128 byte header format, then

Code: Select all

PlayNMI 
   jsr Init  (i know format.. ok init address)
  What mean: "*: jmp *"? 

NMI 
   jsr Play (ok play address)
   rti
can i say to NESASM jsr $8000?, because i will load nsf file, then it's binary file.

Posted: Thu Mar 09, 2006 10:29 am
by Bregalad
jmp * is an intinite loop. If you want to do anything else that playing the NSF, you can of course.
Yeah, you can either read the adress yourself and write them back in your asm file, but a more professional way to use indirect jump [$xxx] to jump to the specified adress in the header if you include it too. If you don't then do it manually.
Since the 6502 don't have inirect jsr [$xxx], you'll have to do this :

Code: Select all

  jsr IndirectInit

IndirectInit:
  jmp [$800x]
For the load adress, you'll have to org it manually. I cannot have a automatic way to have it done. Also, you'll have to remove $80 from the load adress if you include the header. In most NSF it is $8000, so you'll most likely HAVE to not include the header.

Thanks bregalad

Posted: Fri Mar 10, 2006 4:50 am
by lord_Chile
i get it working nsf-nes conversion using DASM and covell script (nes music ripping).. but a strange problem is present.. when init and play dont be default values init=$8003, play=$8000 games doesnt work... i get working 2 nsfs to nes (batman and another catridge)......

double dragon 3.. nsf to nes i cannot get conversion.. some games having rare init or play like $BC03 (this extrange address doesnt work on covell script when i write it).. anyway, mnore later i will present you my conversion process and you will can see what im doing good or bad.. because dd3 doesnt work, i dont know,. it's new for me.. nsf

anyway, can give any details or things that only experts nsf man knows??
i dont mean that you teach me, i like reading very much! only tips. because i cannot get working on dd3 and i think that im doing correct all process because i get batman working.. it must be a detail that i dont know...

ps: any games says on header... 03BC, then i switch it.. because nsf format says lo/hi

lord

help with static status bar bug

Posted: Mon Apr 03, 2006 3:49 pm
by lord_Chile
My question is about static status bar. Im trying make a status bar just like mario bros detecting sprite 0 hit in a part of the money. I can see static status bar while scrolling because i read a topic about it, i understand it, but my static status bar is flickering too much while scrolling. Can someone help to me on it??

I handle code in my main loop, i get vblank by bpl $2002.. it can be my mistake because it miss any frames, i know..
or just im doing something bad??.. My NMI handles to play songs loaded in first 16kb of prg, then i prefer make scrolling in my main loop.

I have loaded 2 nametables with vertical mirror. my scroll goes from a side to another.. and when it reaches the second nametable
it come back to first nametable, it's a loop.

Code: Select all

xxxxx initialitation, etc

turn_screen_on:
	include "SLPE/00.00_to2005.asm"
	lda #%10001000
	sta $2000
	lda #%00011110	
	sta $2001

loop:	
	ldx #$00

.infin              ; our infinite loop that make scroll
	lda $2002
	bpl .infin
.infin2	
	lda $2002
	bpl .infin2

	lda #$00		
	sta $2005
	sta $2005
	jsr w_sprite0_hit

	inx
	stx $2005 
	ldy $2002 
	ldy #%10001000 
	sty $2000 

	txa
	cmp #$FF
	bne .infin

	inc sng_ctr     ; inc song
	lda #$00
	sta int_en
	lda sng_ctr
	jsr INIT_ADD
	lda #$01
	sta int_en

.go_back
	lda $2002
	bpl .go_back

	lda #$00		
	sta $2005
	sta $2005
	jsr w_sprite0_hit

	dex
	stx $2005 
	ldy $2002 
	ldy #%10001000 
	sty $2000 

	txa
	cmp #$00
	bne .go_back

	inc sng_ctr     ; inc song
	lda #MAX_SONG         ;Max Song.
       	cmp sng_ctr
        	bne .no_scr
	lda #$00
 	sta sng_ctr
	
	jmp loop

w_sprite0_hit: 
	bit $2002 
	bvc w_sprite0_hit 
	rts 

Re: help with static status bar bug

Posted: Mon Apr 03, 2006 4:21 pm
by tepples
lord_Chile wrote:My question is about static status bar. Im trying make a status bar just like mario bros detecting sprite 0 hit in a part of the money. I can see static status bar while scrolling because i read a topic about it, i understand it, but my static status bar is flickering too much while scrolling. Can someone help to me on it??

I handle code in my main loop, i get vblank by bpl $2002
You meant the following, right?

Code: Select all

:
  bit $2002
  bpl :-
or just im doing something bad??.. My NMI handles to play songs loaded in first 16kb of prg
Vblank time is no time to play music. You have only 2200 cycles to upload all your graphics into the PPU; use them wisely.
then i prefer make scrolling in my main loop.
You can do it that way too. Have your NMI handler write to a zero page location, and then do your test/branch spin loop on that. Then after you've done all the game logic, you can call the music player.
I have loaded 2 nametables with vertical mirror. my scroll goes from a side to another.. and when it reaches the second nametable
it come back to first nametable, it's a loop.
You need to set the nametable horizontal base address bit (bit 0) of $2000 when the left side of the screen is in the second nametable.

Posted: Mon Apr 03, 2006 4:34 pm
by Disch
The Sprite 0 hit flag doesn't clear at the start of VBlank, it clears at the end of VBlank. So if you check it before the end of VBlank and it yet in the previous frame, it will show high when you read it (even though it hasn't been hit in the upcoming frame yet).

To solve this, when waiting for Sprite 0 hit, unless you're 100% sure VBlank is over when you're checking... first wait for it to go low, then wait for it to come high again:

Code: Select all

w_sprite0_hit:
: bit $2002
  bvs :-  ; wait for it to clear
: bit $2002
  bvc :-  ; wait for it to be set again
  rts

i cannot get what you says tepples

Posted: Thu Apr 13, 2006 5:18 pm
by lord_Chile
Tepples said: "You need to set the nametable horizontal base address bit (bit 0) of $2000 when the left side of the screen is in the second nametable."

When it is??

I have left nametable and right nametable... x scroll increments from #$00 to #$ff. and then it decrements from #$ff to #$00..

Oh, more later i will ask to you something.. because i changue palette like smb1, i try imitate smb1 using smb1 nametables... i imitate sprite 0 hit (static status bar), i imitate sound handling routine.. but imitation of palette changue is difficult for me because i dont know which scroll values can i use in order to send to $2006 for restore scroll. (i made it manually, but i get small glitches)

More later, because i dont have internet in my home. thanks for all..


PS off topic: Nes asm is not so bad... I made a cnrom demo in nes assembler 2.51 hehe.. i will post it more later.. :D

Re: i cannot get what you says tepples

Posted: Thu Apr 13, 2006 6:21 pm
by tepples
lord_Chile wrote:I have left nametable and right nametable... x scroll increments from #$00 to #$ff. and then it decrements from #$ff to #$00..
When the scroll wraps from $ff to $00 (adc turns on carry flag or inc turns on zero flag), toggle bit 0 of the value that you write to $2000. Assuming cur_2000 is a variable in RAM, do this:

Code: Select all

  lda #%00000001
  eor cur_2000
  sta cur_2000
lord_Chile wrote:imitation of palette changue is difficult for me because i dont know which scroll values can i use in order to send to $2006 for restore scroll. (i made it manually, but i get small glitches)
To restore scroll, do this:

Code: Select all

  lda #0
  sta $2005
  sta $2005
  lda cur_2000
  sta $2000

Thanks tepples... now routine optimizations

Posted: Sun Apr 16, 2006 5:53 pm
by lord_Chile
Currently, im working in a algorithm for convert from hex to binary (8 bits): I have programmed 3 algorithms (perfectly working and tested). I would like that if you have best methods for making this conversion, you can share it with me. I have tried each time get more speed. Idea is save each 1 or 0 in one space of 1 byte in order to show more easy it on screen. It is a simulation, using 6502 simulator, then .ORG $0000 would be changed when us are using nes addrs.

Code: Select all

Algorithm 1:
; Program to convert hex 8bit to bin 8bit in 151 cycles

	.ORG $0000	

start:
	LDA #$0A		
	JSR HexToBin8
	BRK
	
HexToBin8:
	LDY #$08
	
.check_end_routine
	DEY
	BMI .end_HexToBin8	
	
.convert_HexToBin8	
	ROR 
	BCS .save_1

.save_0
	LDX #$00	
	STX HexToBin8_output,y
	JMP .check_end_routine
	
.save_1
	LDX #$01
	STX HexToBin8_output,y
	JMP .check_end_routine	
	
.end_HexToBin8	
	RTS
	
HexToBin8_output: 
	       .DB $00,$00,$00,$00,$00,$00,$00,$00
-------------------------------------------------------------------------
Algorithm 2:
; Program to convert hex 8bit to bin 8bit in 137 cycles

	.ORG $0000	; Store machine code starting here

start:
	LDA #$0A		; load hex number to convert
	JSR HexToBin8
	BRK
	
HexToBin8:
	LDY #$07
	
.convert_HexToBin8	
	LDX #$00
	ROR 
	BCC .save_0	; you must use PHP, if you are using NMIS or it can fail

.save_1
	INX	
		
.save_0
	STX HexToBin8_output,y
	DEY
	BPL .convert_HexToBin8	
	
	RTS


HexToBin8_output: 
	       .DB $00,$00,$00,$00,$00,$00,$00,$00
------------------------------------------------------------------------
Algorithm 3:
; Program to convert hex 8bit to bin 8bit in 88 cycles 
;(no counting rts, jsr = 12)

	.ORG $0000	; Store machine code starting here

start:
	LDA #$0A		; load hex number to convert
	JSR HexToBin8
	BRK
	
HexToBin8:
	LDY #$00
	
.convert_HexToBin8	
	ROL
	
	ROL
	TAX
	AND #$01
	STA HexToBin8_output+0
	TXA	
	
	ROL
	TAX
	AND #$01
	STA HexToBin8_output+1
	TXA
	
	ROL
	TAX
	AND #$01
	STA HexToBin8_output+2
	TXA
	
	ROL
	TAX
	AND #$01
	STA HexToBin8_output+3
	TXA
	
	ROL
	TAX
	AND #$01
	STA HexToBin8_output+4
	TXA
	
	ROL
	TAX
	AND #$01
	STA HexToBin8_output+5
	TXA
	
	ROL
	TAX
	AND #$01
	STA HexToBin8_output+6
	TXA
	
	ROL
	AND #$01
	STA HexToBin8_output+7
	
	RTS

HexToBin8_output: 
	       .DB $00,$00,$00,$00,$00,$00,$00,$00

Posted: Sun Apr 16, 2006 6:35 pm
by Disch
bitshifting moves each bit into the C flag. And bit rolling moves bits out of the C flag. The way I'd do it would take advantage of those two facts.

Assuming 'HexToBin8_output+0' is to receive the high bit:

Code: Select all

HexToBin8:
  LDX #$00
  STX HexToBin8_output+0
  STX HexToBin8_output+1
  STX HexToBin8_output+2
  STX HexToBin8_output+3
  STX HexToBin8_output+4
  STX HexToBin8_output+5
  STX HexToBin8_output+6
  STX HexToBin8_output+7   ;clear output

  ASL A
  ROL HexToBin8_output+0
  ASL A
  ROL HexToBin8_output+1
  ASL A
  ROL HexToBin8_output+2
  ASL A
  ROL HexToBin8_output+3
  ASL A
  ROL HexToBin8_output+4
  ASL A
  ROL HexToBin8_output+5
  ASL A
  ROL HexToBin8_output+6
  ASL A
  ROL HexToBin8_output+7

  RTS
That's the "loops unrolled" version (faster, bigger). For the loop version (slower, smaller):

Code: Select all

HexToBin8:
  LDY #$00
  LDX #$07

: STY HexToBin8_output,X
  LSR A
  ROL HexToBin8_output,X
  DEX
  BPL :-

  RTS

EDIT - just realized -- STY only has zero page,X mode -- so that will only work if HexToBin8_Output is in zero page.

hi

Posted: Fri May 05, 2006 10:42 am
by lord_Chile
my question is for emulator developers in visual basic. what is the difference between:

1.-if (var1 and &H56)
2.- if (var1 and &H56&)

what mean ampersands??

Posted: Fri May 05, 2006 1:00 pm
by never-obsolete
1. &H56 is an Integer (2 bytes)
2. &H56& is a Long (4 bytes)

question

Posted: Mon May 08, 2006 1:35 pm
by lord_Chile
how super mario bros keep nametables?. where in rom start nametables?. how many nametables use smb?.

i did try seeing nametables in rom, but i didnt finding nametables starting with hex chain 24 24 24, etc...