Jump to content

Photo

Colossal Cave Adventure diary


243 replies to this topic

#1 vprette OFFLINE  

vprette

    Stargunner

  • 1,340 posts

Posted Sun Jan 29, 2012 12:30 PM

I'd like to share info about the progress of this project from time to time... and of corse receive hints and help from devs out there :-)
be patient with me.

first, I'll spend sometime to set up the environment and make the P-machinery game engine run.
second thing, I found what I believe is the complete text contents of the original game on a repository so I will have idea about dimension of the porting

Edited by vprette, Sun Jan 29, 2012 12:44 PM.


#2 vprette OFFLINE  

vprette

    Stargunner

  • Topic Starter
  • 1,340 posts

Posted Sun Jan 29, 2012 1:01 PM

I donwloaded the SDK 1600 release 4 beta for windows, is this the latest?

#3 vprette OFFLINE  

vprette

    Stargunner

  • Topic Starter
  • 1,340 posts

Posted Sun Jan 29, 2012 2:06 PM

I get error messages for const/ctrl.const
invalid opcode

referring to DEFINE_ENUM(CTRL_KEYPAD, 12)

this command is described in the macro/enum.mac, so why is not working?

Edited by vprette, Sun Jan 29, 2012 3:03 PM.


#4 vprette OFFLINE  

vprette

    Stargunner

  • Topic Starter
  • 1,340 posts

Posted Sun Jan 29, 2012 3:54 PM

So far I started checking some text on screen...

Posted Image

I would like to have few graphic screen like the c64 version

#5 catsfolly OFFLINE  

catsfolly

    Dragonstomper

  • 704 posts
  • Location:Japan

Posted Sun Jan 29, 2012 4:21 PM

I donwloaded the SDK 1600 release 4 beta for windows, is this the latest?


I don't think so.

Try
http://spatula-city....01224-win32.zip

That's the latest release that I know of.

#6 DZ-Jay OFFLINE  

DZ-Jay

    Quadrunner

  • 9,790 posts
  • Triple-Stripe Mo' Bro
  • Location:NC, USA

Posted Mon Jan 30, 2012 7:52 AM

I'd like to share info about the progress of this project from time to time... and of corse receive hints and help from devs out there :-)
be patient with me.

first, I'll spend sometime to set up the environment and make the P-machinery game engine run.
second thing, I found what I believe is the complete text contents of the original game on a repository so I will have idea about dimension of the porting


Valter,

Are you planning on using P-Mach for your Colossal Cave project?

I guess it would work. However, there are a couple of things that P-Mach won't do for you, and you'll have to handle them on your own.

First is that P-Mach offers routines to read the controller keypad and the disc, but does not decode the ECS keyboard. That will need to be added. Extending the controller routine with custom decoders is actually quite simple.

Second, you'll need a routine to emulate a command-line, accepting a character at a time, and processing the command when "enter" is keyed.

Third, you'll need a parser and tokenizer. This interprets the ASCII text code strings and allows you to operate on them.

For instance, if the player types "GET LAMP," the interpreter needs to know that the letters G, E, and T represent the verb "get" and correspond to the command "get object." Likewise, the letters L, A, M, and P then need to be interpreted as the noun "lamp," corresponding to the "lamp" object. Only then would your game be able to add the lamp object to the inventory and update the state of the game accordingly.

These things may not be that hard, but they do require some effort.

The good thing is that you only need to write them once and use them for all different commands and actions.

dZ.

Edited by DZ-Jay, Mon Jan 30, 2012 7:55 AM.


#7 vprette OFFLINE  

vprette

    Stargunner

  • Topic Starter
  • 1,340 posts

Posted Tue Jan 31, 2012 8:52 AM

after working on the title screen, I figure out the following steps:

- INTRO: implement welcome voice at the first intro screen (is it possible?) and intro screen disappearing after few seconds
- INIT: implement background music by integrating the Chevallier tracker (I made some attempt unsuccesfully for now), this should loop forever and can be paused by keypad
- PLAY ENGINE: implement state to state to show several text description when pushing the disc or a key (no text insert, at this point is more like a book)
- PLAY ENGINE: implement the parser to reconnaise text insert
- CONTENTS: include all the booktext and reconnaisable words
- DEFINE KEYPADS: 8 directions, pause music, read more by disc
- SCORE: how to implement scoring??

Edited by vprette, Tue Jan 31, 2012 9:39 AM.


#8 vprette OFFLINE  

vprette

    Stargunner

  • Topic Starter
  • 1,340 posts

Posted Wed Feb 1, 2012 4:52 AM

Welcome voice needs intellivoice added to ECS, so at the moment I avoid this... let's concentrate on the state after state programming.
So far I'm at the status 0.1 (title screen and intro message): I accept encouragement messages :-)

Posted Image

Edited by vprette, Wed Feb 1, 2012 4:57 AM.


#9 vprette OFFLINE  

vprette

    Stargunner

  • Topic Starter
  • 1,340 posts

Posted Wed Feb 1, 2012 9:56 AM

I need to lower some expectation due to the complexity of the coding, in fact pausing the music is not easy to implement, it's easier I guess to stop the music and restart it.. but at the moment all this is far from my capacities so I set more simple milestones for my project.

- INTRO: implement welcome screen disappearing after few seconds
- INIT: implement background music by integrating the Chevallier tracker, this should loop forever
- PLAY ENGINE: implement level to level to show several text description when pushing the disc or a key (like pages of a book)
- PLAY ENGINE: implement input from keypad (8 directions, and disc touch)
- PLAY ENGINE: implement text input from keyboard
- PLAY ENGINE: implement the parser to reconnaise text commands inserted
- CONTENTS: include all the booktext and reconnaisable words
- SCORE: how to implement scoring??

#10 DZ-Jay OFFLINE  

DZ-Jay

    Quadrunner

  • 9,790 posts
  • Triple-Stripe Mo' Bro
  • Location:NC, USA

Posted Wed Feb 1, 2012 11:48 AM

I need to lower some expectation due to the complexity of the coding, in fact pausing the music is not easy to implement, it's easier I guess to stop the music and restart it.. but at the moment all this is far from my capacities so I set more simple milestones for my project.

- INTRO: implement welcome screen disappearing after few seconds
- INIT: implement background music by integrating the Chevallier tracker, this should loop forever
- PLAY ENGINE: implement level to level to show several text description when pushing the disc or a key (like pages of a book)
- PLAY ENGINE: implement input from keypad (8 directions, and disc touch)
- PLAY ENGINE: implement text input from keyboard
- PLAY ENGINE: implement the parser to reconnaise text commands inserted
- CONTENTS: include all the booktext and reconnaisable words
- SCORE: how to implement scoring??


Pausing the music is simple: you stop updating the tracker state.

There's a routine from Arnauld's tracker that you need to call periodically to update the tracker state. You stop calling that routine for the duration of the pause.

You also need to quiet out the PSG (sound chip)
By setting the volume register to zero. I'll send you some code later this week when I return.

About key input, if you're expecting to use the controller, then P-Mach offers a decoder for that. You just need to write the logic for what to do on each key.

Regarding scoring, you can just define a global variable. Check out the constants files, there may be one already defined.

Also, check out the text file included in the docs directory of P-Mach. It offers at least an introduction of the theory behind P-Machinery. It is not finished, but it is a start.
dZ.

#11 vprette OFFLINE  

vprette

    Stargunner

  • Topic Starter
  • 1,340 posts

Posted Thu Feb 2, 2012 7:04 AM

Added text for 8 levels and implemented the return from state/level (but I need to make it depending on input! now is just moving from one page to other to the end :-))

Also I changed the colors to green on black.. is this the best choice?
Posted Image

I have also a box template made... but this is too early to show :-)

one nice add would be using self made fonts.... this I know is possible but again too much work to do... so just an idea

Edited by vprette, Thu Feb 2, 2012 7:33 AM.


#12 DZ-Jay OFFLINE  

DZ-Jay

    Quadrunner

  • 9,790 posts
  • Triple-Stripe Mo' Bro
  • Location:NC, USA

Posted Thu Feb 2, 2012 9:29 AM

Added text for 8 levels and implemented the return from state/level (but I need to make it depending on input! now is just moving from one page to other to the end :-))

Also I changed the colors to green on black.. is this the best choice?
Posted Image

I have also a box template made... but this is too early to show :-)

one nice add would be using self made fonts.... this I know is possible but again too much work to do... so just an idea


Hey, Valter, I'm back home! Let's get this puppy on going. I'm going to review the P-Machinery code right now just to freshen up on it, and will see how we can best tackle your tasks.

Let's concentrate on a few at firsts. What are your current tasks or issues? I can then help you with sample code or something.

In the meantime, I'll post the missing "pause.asm" file in the other P-Machinery thread for you and others.

-dZ.

#13 catsfolly OFFLINE  

catsfolly

    Dragonstomper

  • 704 posts
  • Location:Japan

Posted Thu Feb 2, 2012 9:31 AM

Added text for 8 levels and implemented the return from state/level (but I need to make it depending on input! now is just moving from one page to other to the end :-))

Also I changed the colors to green on black.. is this the best choice?
Posted Image

I have also a box template made... but this is too early to show :-)

one nice add would be using self made fonts.... this I know is possible but again too much work to do... so just an idea

I like the green text on a black background.

Maybe you could find a publicly available 8x8 font that you could adapt and use. I think the Jupiter Ace rom has been released into the public domain. It had an 8x8 font I think... Just a thought.

Would the colossal cave purists be offended if the text included lower case letters? I find lower case letters easier to read, but I realize that the original game was probably all upper case...

Edited by catsfolly, Thu Feb 2, 2012 9:32 AM.


#14 vprette OFFLINE  

vprette

    Stargunner

  • Topic Starter
  • 1,340 posts

Posted Thu Feb 2, 2012 9:44 AM

Added text for 8 levels and implemented the return from state/level (but I need to make it depending on input! now is just moving from one page to other to the end :-))

Also I changed the colors to green on black.. is this the best choice?
Posted Image

I have also a box template made... but this is too early to show :-)

one nice add would be using self made fonts.... this I know is possible but again too much work to do... so just an idea


Hey, Valter, I'm back home! Let's get this puppy on going. I'm going to review the P-Machinery code right now just to freshen up on it, and will see how we can best tackle your tasks.

Let's concentrate on a few at firsts. What are your current tasks or issues? I can then help you with sample code or something.

In the meantime, I'll post the missing "pause.asm" file in the other P-Machinery thread for you and others.

-dZ.


what I need now is:

- implement the waiting loop of 3 seconds, that I use in the welcome screen and maybe somewhere else (TASK
- integrate the audio tracker to start a forevew song from level1... the song I have to translate, but I would use the one of the trackerdemo for now (demosong) just to see if it's working
- add you in the credits for the much help you provide :-)


pause.asm what is made for?

Edited by vprette, Thu Feb 2, 2012 9:46 AM.


#15 vprette OFFLINE  

vprette

    Stargunner

  • Topic Starter
  • 1,340 posts

Posted Thu Feb 2, 2012 9:51 AM

I like the green text on a black background.

Maybe you could find a publicly available 8x8 font that you could adapt and use. I think the Jupiter Ace rom has been released into the public domain. It had an 8x8 font I think... Just a thought.

Would the colossal cave purists be offended if the text included lower case letters? I find lower case letters easier to read, but I realize that the original game was probably all upper case...


purists do not even want banckground music, but I'll add this... :-)
I believe the upper case is more effective

#16 DZ-Jay OFFLINE  

DZ-Jay

    Quadrunner

  • 9,790 posts
  • Triple-Stripe Mo' Bro
  • Location:NC, USA

Posted Thu Feb 2, 2012 10:04 AM

I like the green text on a black background.

Maybe you could find a publicly available 8x8 font that you could adapt and use. I think the Jupiter Ace rom has been released into the public domain. It had an 8x8 font I think... Just a thought.

Would the colossal cave purists be offended if the text included lower case letters? I find lower case letters easier to read, but I realize that the original game was probably all upper case...


I like the green on black, but perhaps you can try with the brighter green and see how it looks?

Regarding fonts, that's simple: Just load the character set into GRAM and you can still use the PRINT routines included in the SDK-1600, by setting the offset from GRAM in the attributes word. You would need letters, numbers, and some punctuation, which shouldn't take more than about 40 GRAM cards. Unless you want mixed-case, which takes considerably more.

Attached is a simple font set I created originally for Christmas Carol, before I decided to stylize them. They are a bit boxy, but less so than the built-in ROM font.

Use it freely as you wish.

-dZ.

Attached File  fonts_tile.asm   14.57KB   104 downloads

Edited by DZ-Jay, Thu Feb 2, 2012 10:16 AM.


#17 DZ-Jay OFFLINE  

DZ-Jay

    Quadrunner

  • 9,790 posts
  • Triple-Stripe Mo' Bro
  • Location:NC, USA

Posted Thu Feb 2, 2012 10:14 AM

Added text for 8 levels and implemented the return from state/level (but I need to make it depending on input! now is just moving from one page to other to the end :-))

Also I changed the colors to green on black.. is this the best choice?
Posted Image

I have also a box template made... but this is too early to show :-)

one nice add would be using self made fonts.... this I know is possible but again too much work to do... so just an idea


Hey, Valter, I'm back home! Let's get this puppy on going. I'm going to review the P-Machinery code right now just to freshen up on it, and will see how we can best tackle your tasks.

Let's concentrate on a few at firsts. What are your current tasks or issues? I can then help you with sample code or something.

In the meantime, I'll post the missing "pause.asm" file in the other P-Machinery thread for you and others.

-dZ.


what I need now is:

- implement the waiting loop of 3 seconds, that I use in the welcome screen and maybe somewhere else (TASK
- integrate the audio tracker to start a forevew song from level1... the song I have to translate, but I would use the one of the trackerdemo for now (demosong) just to see if it's working
- add you in the credits for the much help you provide :-)


pause.asm what is made for?


Valter,

I'll be sending some sample code within the next few hours for those tasks and some instructions and suggestions on how they could be implemented using P-Mach.

The "pause.asm" allows you to pause and un-pause a scheduled task during execution. Normally, you can either Start a scheduled task, or Stop it. This module offers routines that allow you to Pause the task temporarily. When you Un-Pause it later, it will continue ticking down from where it left off.

It is useful, but not necessary. I just include it for completion's sake, since my Christmas Carol and Pac-Man games use it.

An example of it's use: When a Christmas Carol level starts, a timer is engaged to release the Snowman. However, every time Carol eats a "magical snowflake," it gives Carol the ability to avoid danger by confusing the enemies. Consequently, I "pause" the Snowman attack timer temporarily while the snowflake's effect is on, and then un-pause it when the invulnerability period ends.

The result is that, as long as Carol eats snowflakes, the Snowman's attack is delayed.

-dZ.

#18 vprette OFFLINE  

vprette

    Stargunner

  • Topic Starter
  • 1,340 posts

Posted Thu Feb 2, 2012 12:19 PM

when I read your explanation, I feel like little boy at school studying foreign language :-)
I put back the fonts in the task list...

Edited by vprette, Thu Feb 2, 2012 12:22 PM.


#19 DZ-Jay OFFLINE  

DZ-Jay

    Quadrunner

  • 9,790 posts
  • Triple-Stripe Mo' Bro
  • Location:NC, USA

Posted Thu Feb 2, 2012 1:01 PM

what I need now is:

- implement the waiting loop of 3 seconds, that I use in the welcome screen and maybe somewhere else (TASK
- integrate the audio tracker to start a forevew song from level1... the song I have to translate, but I would use the one of the trackerdemo for now (demosong) just to see if it's working
- add you in the credits for the much help you provide :-)


pause.asm what is made for?


Implementing the 3 second wait loop is easy. Let's do that first.

If you read my "P-Machinery Theory" post, then you should by now think of this 3-second delay as no more than a scheduled event that needs to be triggered after three seconds. Therefore, you write your "event handler," which is just the code that will execute once that 3-second delay is up, and schedule it as a task.

The following code is an example of how to schedule the task:

	CALL	STARTTASK
	DECLE   TASK.Delay		  ; Task number
	DECLE   DO_SOMETHING		; Event handler
	DECLE   (60 * 3 * 2) - 1	; 60 frames per second times 3
	DECLE   0				   ; No re-schedule

As I mentioned before, there are two timing counts that you provide the STARTTASK procedure. The first one is the "initial delay" and the second one is the re-schedule time. The latter is only used for recurring tasks.

Since yours is a one-off task, we set the first count to an odd number (that's why the "-1"), and we set the re-schedule delay to zero to ignore it.

That's it. You're done. The P-Mach engine will iterate doing its thing for 180 iterations (3 seconds at 60 Hz), and call the routine DO_SOMETHING when the timer is up. (Note that "DO_SOMETHING" is a placeholder for whatever task you make.)

In your DO_SOMETHING routine you do whatever needs to happen at that point. Let's say you want to clear the screen, then you do this:

DO_SOMETHING PROC
	CALL	CLRSCR

	TRET	; done!
	ENDP

Here's an interesting thing to note: When one of your procedures is intended to be called ONLY from the task scheduler, then you do not need to worry about keeping track of the return address. The TRET (Task Return) macro "hard-wires" the return address to the task scheduler.

In other words, the scheduler triggers your event, and your event returns directly so that the scheduler may continue with other tasks.

However, if the routine needs to be called directly (using CALL), then you can't use TRET. You'll have to keep track of the return address and return normally.

At what point do you want to introduce the 3 second delay, and what do you want it to do after?

-dZ.

Edited by DZ-Jay, Thu Feb 2, 2012 1:06 PM.


#20 DZ-Jay OFFLINE  

DZ-Jay

    Quadrunner

  • 9,790 posts
  • Triple-Stripe Mo' Bro
  • Location:NC, USA

Posted Thu Feb 2, 2012 1:25 PM

what I need now is:

- implement the waiting loop of 3 seconds, that I use in the welcome screen and maybe somewhere else (TASK
- integrate the audio tracker to start a forevew song from level1... the song I have to translate, but I would use the one of the trackerdemo for now (demosong) just to see if it's working
- add you in the credits for the much help you provide :-)


pause.asm what is made for?


Now let's deal with the audio tracker updates. You want to play music during the "game-play" state, while the game is engaged, right?

Simple again! All you need to do is periodically call the TRKPLAY procedure from Arnauld's tracker, assuming that you have already called TRKSNGINIT during initialization. By periodically we actually mean, on every ISR interrupt, or on every game-loop iteration.

However, note that the PSG (the sound chip) does not have any access restrictions like the STIC (the video chip). Therefore, we are not constrained to call TRKPLAY during VBLANK. We are safe to call it at any time, as long as we call it once on every loop iteration.

In Christmas Carol, I call the TRKPLAY routine from two centralized points: During the game-play event handler, and during the wait event handler. The former should be self-explanatory by now. The latter, however, warrants some explanation.

P-Machinery allows you to break each main state into sub-states. Along these sub-states there is typically a need for a "wait" state, in which the game engine is doing absolutely nothing but ticking along updating the engine state without any particular game logic to execute.

This is common, for example, when introduce a delay between screen transitions, or when you switch from one main state to another. Indeed, it is so common, that P-Machinery includes a generalized wait state routine called the "wait engine."

The "wait engine" typically does all the housekeeping stuff that the other states need to do, with the exception of game-specific logic, such as collision detection, etc. In essence, it puts the game into an "idle" state, processing timers and other tasks but doing no real game stuff.

The "wait engine" handler in P-Machinery is the routine ST_WAIT_ENGINE in the "engine_util.asm" file. Below is the code currently in P-Mach for this procedure:


;; ======================================================================== ;;
;;  ST_WAIT_ENGINE                                                          ;;
;;  Procedure to service all timers.                                        ;;
;;                                                                          ;;
;;  INPUT for ST_WAIT_ENGINE                                                ;;
;;      None.                                                               ;;
;;                                                                          ;;
;;  OUTPUT                                                                  ;;
;;      None.                                                               ;;
;; ======================================================================== ;;
ST_WAIT_ENGINE  PROC
                ; --------------------------------------
                ; These access GRAM or the STIC, and so
                ; need to run as soon as possible at the
                ; top of the ISR routine.
                ; --------------------------------------
                ISR_ENABLE_DISPLAY
                CALL    POST_STIC_X

@@Task:         ; --------------------------------------
                ; This is a good place to update music
                ; and sound effects states, too.
                ; --------------------------------------

                MVII    #@@__wait_tsk,          R0      ; \_ Set up a task to process timers
                DCALL   QTASK,  iIgnore                 ; /
                IRET

                ; --------------------------------------
                ; Process timed tasks and check for
                ; a request to pause the game.
                ; --------------------------------------
@@__wait_tsk:   DCALL   DOTIMER, iEnabled
                TCHAIN  PAUSE_GAME                      ; Check for pause
                ENDP

Notice the place holder in the @@Task label. It is indeed a good place to update music states. Just add "CALL TRKPLAY" at that point. Also notice the rest of the basic tasks that the wait engine performs: it sets up a task to process all timers (for scheduled tasks), enables active display, and updates the STIC (video chip) registers.

To play music during game-play, you do something similar in the routine ST_LVL_PLAY in the "st_level.asm" file. That is the handler for the "Game-Play" state. That routine has a similar placeholder for normal game-engine background stuff:

;; ======================================================================== ;;
;;  ST_LVL_ENGINE: ISR routine to handle a game level.                      ;;
;; ======================================================================== ;;
ST_LVL_PLAY     PROC
                ; --------------------------------------
                ; These access GRAM or the STIC, and so
                ; need to run as soon as possible at the
                ; top of the ISR routine.
                ; --------------------------------------
                ISR_ENABLE_DISPLAY
                CALL    POST_STIC_X

                ; --------------------------------------
                ; Perfom all engine tasks or add them
                ; to the task queue as necessary:
                ;   - Update STIC
                ;   - Update PSG
                ;   - Cycle GRAM cards
                ;   - Update score display
                ;   - Move all sprites
                ;   - Check collisions
                ;   - Animate sprites
                ;   - etc.
                ; --------------------------------------

                ; --------------------------------------
                ; Process all timed tasks and counters.
                ; --------------------------------------
                DCALL   DOTIMER, iEnabled
                CALL    PAUSE_GAME                      ; Check for pause
                IRET
                ENDP

Like I mentioned in the "P-Machinery Theory" post, rather than writing the code in-line at this point, you should just add the tasks to the queue. This will allow P-Machinery to act in a sort of "multi-tasking" way. Rather than processing a long, single flow of code on each iteration, it processes multiple short tasks in rapid-fire fashion.

This allows the engine to be flexible with time: if at any point it doesn't have enough time to process all tasks in one go, the next game-loop iteration will just add more tasks to the queue, provided there is enough space in the queue. Since the queue is processed in order, they don't collide with each other. Eventually the engine should catch up and everything continues as normal.

I hope this helps.

-dZ.

Edited by DZ-Jay, Thu Feb 2, 2012 1:40 PM.


#21 vprette OFFLINE  

vprette

    Stargunner

  • Topic Starter
  • 1,340 posts

Posted Thu Feb 2, 2012 1:52 PM

what I need now is:

- implement the waiting loop of 3 seconds, that I use in the welcome screen and maybe somewhere else (TASK
- integrate the audio tracker to start a forevew song from level1... the song I have to translate, but I would use the one of the trackerdemo for now (demosong) just to see if it's working
- add you in the credits for the much help you provide :-)


pause.asm what is made for?


Implementing the 3 second wait loop is easy. Let's do that first.

If you read my "P-Machinery Theory" post, then you should by now think of this 3-second delay as no more than a scheduled event that needs to be triggered after three seconds. Therefore, you write your "event handler," which is just the code that will execute once that 3-second delay is up, and schedule it as a task.

The following code is an example of how to schedule the task:

	CALL	STARTTASK
	DECLE   TASK.Delay		  ; Task number
	DECLE   DO_SOMETHING		; Event handler
	DECLE   (60 * 3 * 2) - 1	; 60 frames per second times 3
	DECLE   0				   ; No re-schedule

As I mentioned before, there are two timing counts that you provide the STARTTASK procedure. The first one is the "initial delay" and the second one is the re-schedule time. The latter is only used for recurring tasks.

Since yours is a one-off task, we set the first count to an odd number (that's why the "-1"), and we set the re-schedule delay to zero to ignore it.

That's it. You're done. The P-Mach engine will iterate doing its thing for 180 iterations (3 seconds at 60 Hz), and call the routine DO_SOMETHING when the timer is up. (Note that "DO_SOMETHING" is a placeholder for whatever task you make.)

In your DO_SOMETHING routine you do whatever needs to happen at that point. Let's say you want to clear the screen, then you do this:

DO_SOMETHING PROC
	CALL	CLRSCR

	TRET	; done!
	ENDP

Here's an interesting thing to note: When one of your procedures is intended to be called ONLY from the task scheduler, then you do not need to worry about keeping track of the return address. The TRET (Task Return) macro "hard-wires" the return address to the task scheduler.

In other words, the scheduler triggers your event, and your event returns directly so that the scheduler may continue with other tasks.

However, if the routine needs to be called directly (using CALL), then you can't use TRET. You'll have to keep track of the return address and return normally.

At what point do you want to introduce the 3 second delay, and what do you want it to do after?

-dZ.


it's working
I introduce 3 seconds in the first page with message welcome stranger.. after 3 second goes to first description.
I may also use this to pretend the text on screen is written in two steps (half page right away and half page after 2 seconds) but do not know if the result is interesting or confusing

#22 DZ-Jay OFFLINE  

DZ-Jay

    Quadrunner

  • 9,790 posts
  • Triple-Stripe Mo' Bro
  • Location:NC, USA

Posted Thu Feb 2, 2012 2:01 PM

what I need now is:

- implement the waiting loop of 3 seconds, that I use in the welcome screen and maybe somewhere else (TASK
- integrate the audio tracker to start a forevew song from level1... the song I have to translate, but I would use the one of the trackerdemo for now (demosong) just to see if it's working
- add you in the credits for the much help you provide :-)


pause.asm what is made for?


Implementing the 3 second wait loop is easy. Let's do that first.

If you read my "P-Machinery Theory" post, then you should by now think of this 3-second delay as no more than a scheduled event that needs to be triggered after three seconds. Therefore, you write your "event handler," which is just the code that will execute once that 3-second delay is up, and schedule it as a task.

The following code is an example of how to schedule the task:

	CALL	STARTTASK
	DECLE   TASK.Delay		  ; Task number
	DECLE   DO_SOMETHING		; Event handler
	DECLE   (60 * 3 * 2) - 1	; 60 frames per second times 3
	DECLE   0				   ; No re-schedule

As I mentioned before, there are two timing counts that you provide the STARTTASK procedure. The first one is the "initial delay" and the second one is the re-schedule time. The latter is only used for recurring tasks.

Since yours is a one-off task, we set the first count to an odd number (that's why the "-1"), and we set the re-schedule delay to zero to ignore it.

That's it. You're done. The P-Mach engine will iterate doing its thing for 180 iterations (3 seconds at 60 Hz), and call the routine DO_SOMETHING when the timer is up. (Note that "DO_SOMETHING" is a placeholder for whatever task you make.)

In your DO_SOMETHING routine you do whatever needs to happen at that point. Let's say you want to clear the screen, then you do this:

DO_SOMETHING PROC
	CALL	CLRSCR

	TRET	; done!
	ENDP

Here's an interesting thing to note: When one of your procedures is intended to be called ONLY from the task scheduler, then you do not need to worry about keeping track of the return address. The TRET (Task Return) macro "hard-wires" the return address to the task scheduler.

In other words, the scheduler triggers your event, and your event returns directly so that the scheduler may continue with other tasks.

However, if the routine needs to be called directly (using CALL), then you can't use TRET. You'll have to keep track of the return address and return normally.

At what point do you want to introduce the 3 second delay, and what do you want it to do after?

-dZ.


it's working
I introduce 3 seconds in the first page with message welcome stranger.. after 3 second goes to first description.
I may also use this to pretend the text on screen is written in two steps (half page right away and half page after 2 seconds) but do not know if the result is interesting or confusing


Valter, considering that you only have a 20 x 12 matrix in which to display the text, how do you plan on showing long text passages? Perhaps you should consider editing the text for space, making it shorter.

Also, how about just showing a small icon on the right-most bottom of the screen (e.g. an ellipsis, or an arrow, or the word "more" in tiny text) to alert the user that there is more text to display? Then you just wait for any key from the user (or a press of the disc) and display the next "page."

I have a rush of memories of making my own text-based games in the C=64 when I was younger, all peppered with a "[press space to continue]" message at the bottom of the screen in reversed-video. :)

-dZ.

Edited by DZ-Jay, Thu Feb 2, 2012 2:02 PM.


#23 DZ-Jay OFFLINE  

DZ-Jay

    Quadrunner

  • 9,790 posts
  • Triple-Stripe Mo' Bro
  • Location:NC, USA

Posted Thu Feb 2, 2012 2:06 PM

Valter, if you are using a Mac, and assembling from the command line, P-mach includes two handy shell scripts to compile and run: "build.sh" and "run.sh". They also work on Linux and other UNIX-based systems.

-dZ.

#24 vprette OFFLINE  

vprette

    Stargunner

  • Topic Starter
  • 1,340 posts

Posted Thu Feb 2, 2012 2:11 PM

Valter, considering that you only have a 20 x 12 matrix in which to display the text, how do you plan on showing long text passages? Perhaps you should consider editing the text for space, making it shorter.

Also, how about just showing a small icon on the right-most bottom of the screen (e.g. an ellipsis, or an arrow, or the word "more" in tiny text) to alert the user that there is more text to display? Then you just wait for any key from the user (or a press of the disc) and display the next "page."

-dZ.


this is exaclty what I have planned in the beginning

#25 vprette OFFLINE  

vprette

    Stargunner

  • Topic Starter
  • 1,340 posts

Posted Thu Feb 2, 2012 3:18 PM

Well
tracker still does not sing for me :-).....

I try to resume:

1- I included all the tracker files
INCLUDE "tracker.asm"
INCLUDE "tracker.mac"
INCLUDE "demosong.asm"
in the p-math.asm
no error, so I proceed
2- I call the initializations in the PROC ST_LVL_INIT inside "st_level.asm" as

CALL TRKINIT ; initialize tracker
CALL TRKSNGINIT ; initialize song


3- I call the song in ST_WAIT_ENGINE in the "engine_util.asm" as
; --------------------------------------
; This is a good place to update music
; and sound effects states, too.
; --------------------------------------
CALL TRKPLAY

this is not working, the rom is killed after title screen.... I maybe tired and need to sleep :-)




0 user(s) are browsing this forum

0 members, 0 guests, 0 anonymous users