Animated tiles

Hello all i have been working on animated tiles, im sure by the time i figure one out 4.x.x will be out and already have them as a usable feature.

But i have been doing research and wanted to post this code and see how far away this is from being usa le in NESMAKER. NOW this is not my code i sources if from Nerdy Nights




.inesmap 30 ;mapper30= NROM
.ineschr #2
.bank ;just make a new .bank file below your current CHR file, giving the next seq number and the
;when you set ehich bank to switch to this is the number used. PRG bank numbers are ignored so your original CHR bank will be #0
;and the new one will be #1
;(below the current one int the folder.
;Subroutine time.

....my game code...

LDA #$01;;; put the new bank to use into the A register
JSR Bankswitch ;;Vump to bank switch code
....My game code...

Bankswitch

STA $8000 ;;new bank to use

RTS

;;NO bus COnflict

LDA #$01 ; PUT NEW BANK TO USE into A

JSR Bankswitch ;;jump to bank switching code

...code...

Bankswitch

TAX;;copy A into X
STA Bankvalues, X;;new bank to use
RTS

Bankvalues

.db $00, $01, $02, $03;; bank numbers


As im working through ASM and NESMAKER locating CHR files in nesmaker im taking are the BACKGROUND CHR files and then the Code would be writen to the tile.
 

Mugi

Member
well, for starters, this is not even assembly, it's C, making inherently incompatible with nesmaker.
it's propably for ca65 which is a C compiler and could be ported to asm6 but as it is it wont do anything in nesmaker.

(the link is not working btw)
 
Ok so i switch the code it has to do with bankswitching. Im trying to learn ASM, and this is how i do so with with trial and error.

Can this be used in an animated tile application?
 
Thank for the help Mugi. With a Swap code i have working in nemaker now , coding in which graphics banks and it will be animating shortly ;)
 

mouse spirit

Well-known member
This sounds great.Would it be possible to just do something with monster locks code or something like that?Like just switch from one tile to another, but then back again?
 

dale_coop

Moderator
Staff member
The code for replacing a tile is really consuming... if you don't that repeatedly, your game will be very laggy and glitchy.

Currenlty, two solutions: using an object, that would have no collision, and be ignoring gravity... just make it flashing/changing like you want.
Or you can use palette cycling (colors changes), like that topic: http://nesmakers.com/viewtopic.php?p=25049#p25049
 

voltopt

Member
I just tried this and I have a silly question: I can't figure out where to place the first three line part of code. You mention lime 50 of "the code" and I assume this means the demo.txt export file.
 

dale_coop

Moderator
Staff member
voltopt said:
I just tried this and I have a silly question: I can't figure out where to place the first three line part of code. You mention lime 50 of "the code" and I assume this means the demo.txt export file.

Wow, no. You never modify the demo.txt
You need to read the entier tiopic (from the 1st message ;) the tutorial is there... and then, I explain how to modify my code to use it differently) ;)

Quick question... Have you watched the tutorial videos? Those videos explain how NESmaker works, how to use it, the concepts, the settings, ... and how to customize scripts, ...
If you haven't yet, stop everything you are doing and what the tutorials: if you are using the 4.5 version the tutorials are on the official web page in the LEARN section. And if using the 4.1.5 the older tutorials are on the official youtube channel.
 

voltopt

Member
Yes, I've watched all tutorials and implemented the concepts in 4.5.2 in three different test projects, going back and rewatching certain parts to drill the concept home. Most basic things are simple and easy to understand. I did not read all the way back to the beginning of the animation post; the tutorial mentions "the code" but I didn't find the .asm file / subroutine that would be called/edited. I'll read back from the first post and see if I can figure it out. Editing the demo.txt seemed like the wrong move, but I refer to it to understand the executable flow of the rom.
 

dale_coop

Moderator
Staff member
The original post is just talking about the concept. Nothing here is useable as it, in NESmaker.
Now the original poster should find where to place some parts of that code in NESmaker, in some different scripts, ... and looks like he hasn't find yet.
In fact, nobody here made made animated tiles (except Mugi, but his project doesn't really use NESmaker anymore).

Everyone use objects or use palette cycling, to simulate animated stuffs.

General rule: in NESmaker, as shown in the tutorials, when you need to modify scripts, you edit/modify them from the "Project Scripts > Script Settings" (for game engine) or from the "Scripts > Input Scripts" list (if for inputs). You can duplicate some of them to make customized ones, like explained in the videos.
Basically, that's it. But demo.txt is not a script... it's the temporary file that is generated to be compiled into the ROM file. That demo.txt file is an export of all the scripts used by your project... and it's overwritten each time you Export ("export & test") your project.
 

voltopt

Member
Exactly. When I've edited scripts I've created a new subfolder for the project, and done exactly what you described. My visit to demo.txt is mainly to understand the program flow, not to do anything to it specifically. I appreciate your responses, thank you!
 

voltopt

Member
Also, it was palette cycling I was exploring in the older thread. I probably hurriedly asked the question in an incomplete way
 

mouse spirit

Well-known member
Well i want animated tiles! I feel like to only change the graphic would not cause too much stoppage or lag, but changing actual tiles does. Someone correct me here. I did have it working just fine.. but only when i would interact with the tile. I could change the graphic back and forth with my melee weapon.
 

voltopt

Member
So I finally had a chance to look back at the 4.1.5 doHandleGameTimer code and implemented Dale's recommendation, using screen type to call palette cycling. One problem - on compile, I get the "Illegal instruction" error, which is the last part of the code that moves palette color 1 to 3.

Code:
    STY bckPal+3,x		;; move pocket (y) to 3

Everything about the code is (currently) identical to what was shared in May (I wanted to test it before customization); is this code not compatible w/ 4.5.2?
 

voltopt

Member
dale_coop said:
This line should work in 4.5 too.
Maybe it's not the line of your error?

Maybe, although the compiler references line 104, which I shared in my last post

I followed the guide for 4.1.5 from May;

Added a variable :
jXvQ27.png


Copied the code you shared (almost exactly, the only change was to comment out the screenSpeed BEQ and uncomment screenType)

Code:
;;; handle game timer.
	LDA gameTimerTicks
	CLC
	ADC #$01 ;; change this to how fast you want the timer to run.
	STA gameTimerTicks
	LDA gameTimerLo
	ADC #$00
	STA gameTimerLo
	LDA gameTimerHi
	ADC #$00
	STA gameTimerHi
	
	
HandleGameTimer:
	
	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	;; dale_coop : call of the palette cycling code (see the routine at the end of this script):
	JSR handlePaletteCycleTimer
	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	
	DEC gameTimer
	BNE dontUpdateGameTimer
	LDA gameTimerLo
	CLC
	ADC #$01
	STA gameTimerLo
	LDA gameTimerHi
	ADC #$00
	STA gameTimerHi
;;;;;;;;;;;;;;;;;;;;;;;;;;; 
	;; DO WHATEVER READS OF THE GAMETIMER YOU MIGHT WANT HERE.
	JSR DoAlarm
;;;;;;;;;;;;;;;;;;;;;;;;;;;
	LDA #DayNightSpeed
	STA gameTimer
dontUpdateGameTimer:
	RTS
	
DoAlarm:
	
	;;; we're going to edge-load monsters one at a time if they are of edge type and are not active.
;;	LDX #$00
;;doLoadMonsterOnTimerLoop:

;;	LDA edgeLoaderInCue
;;	BEQ noEdgeMonstersInCue
;;	LDA currentBank
;;	STA prevBank
;;	LDY #$1C ;; data bank
;;	JSR bankswitchY
;;	JSR CreateTimedEdgeSpawner
;;	DEC edgeLoaderInCue
;;	LDY prevBank
;;	JSR bankswitchY

;;noEdgeMonstersInCue
;;	RTS
	
	
	
;;;;;;;;;;;;;;;;;;; PALETTES CYCLE  ;;;;;;;;;;;;;;;;;;;
handlePaletteCycleTimer:
    ;; Pal cycling on START SCREEN :
    LDA update_screen_details	;; special screen (start/win screens)?
    BNE +						;; if not skip the pal cycle code
    LDA currentScreen		;; screen 0 (the start one)?
    BEQ doPaletteCycleTimer 	
	;; if not skip the pal cycle code
	+	
	
	;; Pal cycling on "Medium"-speed screens :
	;LDA screenSpeed
	;CMP #$01
	;BEQ doPaletteCycleTimer

	;; another example, Pal cycling on screen type 255 screens :
	LDA screenType
	CMP #255
	BEQ doPaletteCycleTimer

	
	JMP endPaletteCycleTimer
doPaletteCycleTimer: 
    ;; from here, DO the palette cycle:
    LDA palettesCycleTimer
    BNE dontUpdatePaletteCycleTimer
    JSR pickPaletteToCycle
    LDA #$10  			;; HERE !!! the SPEED of the cycling
    STA palettesCycleTimer
dontUpdatePaletteCycleTimer:
    DEC palettesCycleTimer
endPaletteCycleTimer:
    RTS    
pickPaletteToCycle:
    LDA #$02    		;; HERE !!! the "Sub 3" palette
    ASL
    ASL 				;; these multiply your literal or variable with 4 so we can get the right offset for each palette in increments of 4.
    TAX
    LDY bckPal+1,x		;; pocket colour 1 in reg y
    LDA bckPal+2,x 
    STA bckPal+1,x		;; move colour 2 to 1
    LDA bckPal+3,x 
    STA bckPal+2,x		;; move colour 3 to 2
    STY bckPal+3,x		;; move pocket (y) to 3
    LDA #$01
    STA updatePalettes	;; loading anything but zero into this value tells NESmaker it needs to update palettes.
    RTS

Saved an iteration in a project specific folder:

jXvVJr.png


Ran the compile/test, and got the illegal instruction error on line 104:

jXvk0z.png


and a quick screenshot of line 104 of the previously copied doHandleGameTimer_CA.asm script:

jXv6BT.png
 

dale_coop

Moderator
Staff member
Maybe the compiler has been changed (updated) since the 4.1.5...
Instead of:
Code:
	STY bckPal+3,x		;; move pocket (y) to 3
You could try:
Code:
	TYA
	STA bckPal+3,x		;; move pocket (y) to 3

But I am pretty sure that the rest of the code (the original default newsmaker variables like gameTimer or even screenType variable related core will not work, because not sure it has been implemented in this very basic empty 4.5 module... we will have to wait the definitive modules that will come soon)
 

voltopt

Member
Thank you! You are absolutely correct, the variables gameTimer and screenType do not work in the current empty module. Much like the "hide behind" tile script, which flips the background bit to the foreground, we will have to wait. I suppose I have a list of things I want to implement and test upon release!
 

dale_coop

Moderator
Staff member
Yeah... because the current core (module) is reaaaally basic. It was meant to be used with the Summer Camp, just as a learning tool, educational purposes ;)
I think Joe will release more complete modules (and different genre modules) this weekend or next week.
It will be more robust and interesting to work with.... and make real (useful) customizations.

... before the Byte Off Competition starts!
 
Top Bottom