Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 20:37 23 Nov 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : New commands & an adventure type game

Author Message
seco61
Senior Member

Joined: 15/06/2011
Location: Australia
Posts: 205
Posted: 01:49pm 22 Aug 2011
Copy link to clipboard 
Print this post

Hi All.

I have placed on my web site a version of the firmware (and source) based on the v2.5 release. This version contains some additional commands that have been requested and also that I wanted! (Also a couple of bug fixes...). There has also been a fair bit of work speeding up the video system, as well as a few other tweaks.

I have also placed on my web site a rather large adventure type game (VALLEY.BAS) that I have adapted to the Maximite. It makes use of some of the new commands. Also some documentation that describes the background to the game (Valley Documentation.pdf).

I have not played through all the scenarios, so there may be bugs - it was a LOT of typing!

I have also updated the "default" font to include the entire 256 character code page 437 character set. I have also added the ability to update the last 128 characters with programable characters.

The following code will display the font:


100 cls
110 invert 0
200 j = 0
210 for i = 0 to 255
220 vpoke i mod 32, j, i
230 if (i mod 32) = 31 then j = j + 1
240 next i
300 invert 1
310 for i = 0 to 255
320 vpoke i mod 32, j, i
330 if (i mod 32) = 31 then j = j + 1
340 next i
350 invert 0
360 locate 0,16 * 12
400 for i = 1 to 3
410 ? string$(10,176);string$(12,177);string$(10,178)
420 next i
430 invert 1
440 for i = 1 to 3
450 ? string$(10,176);string$(12,177);string$(10,178)
460 next i
470 invert 0
999 end



The new commands are:

TOGGLE will toggle the state of an output pin (and optionally toggle it back after a defined period):

TOGGLE pin [,timer]
where pin is a pin defined as a digital or open collector output (or pin 0 to toggle the LED)
timer is optional and specifies a time in milliseconds for the toggle pulse

The pulse time will be between timer and timer + 1 milliseconds.
If a TOGGLE command for the same pin is issued while a previous command is still "toggling" then the remaining toggle period will be replaced by the new timer value.


INVERT will cause subsequent character writes to the video (ie PRINT, VPOKE and MMBASIC prompts etc, but not the PIXEL command) to be inverted :

INVERT x
where if x is non-zero inversion will occur, if zero turns inversion off

MM.INVERT will return the current state of INVERT


FONTINIT will reset the programable font array to the initial state (standard code page 437):

FONTINIT [char]
where if char is supplied (128 - 255) then just that font character is reset - if not supplied then all 128 programable fonts are reset


FONTPROG will program a programable font :

FONTPROG char, b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12
where char is the font postion to be programed (128 - 255)
b1 - b12 are the values for each row of the font (values 0 - 63 - for the six bit positions)


VLOCATE positions the cursor for the next PRINT command - similar to the existing LOCATE command but operates on integral character positions:

VLOCATE x,y
where x is the column position (0 - 79)
y is the row position (0 - 35)


VPOKE will place a character at a designated position:

VPOKE a,char OR VPOKE x,y,char
where char is the character to be displayed (0 - 255)
a is the array index (as the array is 80 columns by 36 rows this value is between 0 - 2879)
x is the column (0 - 79)
y is the row (0 - 35)


VPEEK will return the character value (0 - 255) at a designated position:

VPEEK(a) OR VPEEK(x,y)
where a is the array index (as the array is 80 columns by 36 rows this value is between 0 - 2879)
x is the column (0 - 79)
y is the row (0 - 35)

The VPOKE command and VPEEK function work on the character positioning where the column value is positioned at an integeral multiple of the font horizontal size (ie 6) and a row value at an integeral multiple of the font vertical size (ie 12). If standard writes (ie PRINT, MMBASIC prompts etc) match this positioning then the VPOKE/VPEEK array is updated with the information and VPEEK will return the correct value. Scrolling of the video display and the CLS command also update the array.


PWM output is available on logical pins 7 - 10. The base PWM frequency can be from 1Hz to 5000Hz. The duty time can be set from 0% to 100%. However, at frequencies above 500Hz the duty time percentage will be rounded (eg at 1000Hz the increments are at 2% and at 5000Hz the increments are 10%).

To set a pin to PWM mode, you use the SETPIN command. The format is:

SETPIN pin,cfg,frequency,pwm
where pin is 7 - 10
cfg is 10 for PWM mode
frequency is 1 - 5000 (for 1Hz to 5000Hz)
pwm is 0 - 100 (for 0% to 100% duty time)

To modify the duty time just issue the SETPIN command again with a different duty time percentage.

An example command:

SETPIN 7,10,500,25 -> set pin 7 to PWM with a frequency of 500Hz and a duty time of 25%
SETPIN 7,10,500,50 -> change the duty time to 50%


I have also provided a PWM command that uses the onboard output compare peripherals. To use this will require connecting to the unused MCU pins 46 (OC1) and/or pin 51 (OC4). As the PWM peripherals have to use either Timer 2 or Timer 3 as a source, I had to use Timer 2 for both peripherals as Timer 3 is used by the current firmware. This means that if you use both PWM outputs the frequency has to be the same for both (but not the duty cycle):

PWM module,freq,duty
where module is 1 or 4 (1 - OC1 on pin 46, 4 - OC4 on pin 51)
freq is 5 - 800000 (5Hz to 800kHz) or 0 to disable the module
duty is 0 - 100 (for 0% to 100% duty cycle)


I have done a rewrite of the pin change code so that the checking is done in a timer routine and updates a count every time the appropriate transition occurs. The new code will reliably handle 5kHz signals provided that the high and low states are at least 100uS.

The check interrupt routine now checks for a non zero count and invokes the interrupt routine if this is the case. The count value is stored in the MM.PCNT psuedo variable and the count value is then zeroed.

This ensures that when the interrupt routine for a pin is executed, if more than one transition has occurred the number that have occurred since the interrupt routine last ran is available in the MM.PCNT psuedo variable.

Enjoy!

Regards

Gerard (vk3cg/vk3grs)
 
sparkey

Senior Member

Joined: 15/06/2011
Location: Australia
Posts: 819
Posted: 02:00pm 22 Aug 2011
Copy link to clipboard 
Print this post

very cool gerard thought u must have been in the mist of something will fire up your code on my altro maxi tonite and thanks for the game even thoug i`m not a "dgame person" but thanks for your efforts regards sparkey ....have loaded the hex on my altro board and will load it into my inverter boaed as well my inverter is working with your software its good and hopefully with your new code we may be able to do other things wit this upgrade thanks gerard .....


::: just run your test program nice character test there and it also runs my inverter program as i have it to set to autorun fired up straight away ooh yes also if u quit the pumppin program"the ifreq generator it does not stop the generator ::until u type new

;;;;;;;Edited by sparkey 2011-08-24
technicians do it with least resistance
 
sparkey

Senior Member

Joined: 15/06/2011
Location: Australia
Posts: 819
Posted: 03:39pm 22 Aug 2011
Copy link to clipboard 
Print this post

::: i now have your hex code running on my inverter and listening to ac/dc live from atlantic studios it works ok cool...regards sparkey.....
technicians do it with least resistance
 
sparkey

Senior Member

Joined: 15/06/2011
Location: Australia
Posts: 819
Posted: 04:27pm 22 Aug 2011
Copy link to clipboard 
Print this post

GERARD i know i have sent you mails but i finally have what i want on the screen is this possable i have current shunts for the amp lines ...

::: is this possable using pin 14 as a freq counter or r u all ready using this if so diss regard repoted freq


MAIN BUS BATTERY VOLTAGE : 28:345

RUNNING FREQ :300 Hz

REPORTED FREQ : READING OFF PIN 14

TWELVE VOLT RAIL :11.876

ADJUSTABLE VOLTAGE RAIL :25,654

UP TIME : 02:43

CURRENT USEAGE AMPS/HR 02:3456

SET FREQ /MARK SPACE RATIO LINE...
technicians do it with least resistance
 
haiqu

Senior Member

Joined: 30/07/2011
Location: Australia
Posts: 152
Posted: 06:21pm 22 Aug 2011
Copy link to clipboard 
Print this post

Looks like you've been very industrious there. Nice work indeed.

Rob

unzip, strip, touch, finger, grep, mount, fsck, more, yes, fsck, fsck, fsck, umount, sleep
 
aargee
Senior Member

Joined: 21/08/2008
Location: Australia
Posts: 255
Posted: 09:38pm 22 Aug 2011
Copy link to clipboard 
Print this post

Great work, Gerard.

I'll give it a whirl later on today!

- Rob.


For crying out loud, all I wanted to do was flash this blasted LED.
 
Bill.b

Senior Member

Joined: 25/06/2011
Location: Australia
Posts: 226
Posted: 12:09am 23 Aug 2011
Copy link to clipboard 
Print this post

hi Gerard

just attepted to run valley.bas. I received an error in line 320 - file number is not open. is there an additional data file required.

the new fonts are great and the ability to program the additional fonts reminds me of my old microbee pcg graphics.

In the interests of the environment, this post has been constructed entirely from recycled electrons.
 
seco61
Senior Member

Joined: 15/06/2011
Location: Australia
Posts: 205
Posted: 12:39am 23 Aug 2011
Copy link to clipboard 
Print this post

  Bill said   hi Gerard

just attepted to run valley.bas. I received an error in line 320 - file number is not open. is there an additional data file required.

the new fonts are great and the ability to program the additional fonts reminds me of my old microbee pcg graphics.


Hi Bill.

Thank you for the report.

Yes, I had forgotten to post the initialisation program - VALYINIT.BAS.

This program needs to be run once and stores 3 files on the SD Card that the program uses. As this implies, the VALLEY program (in its current form) requires an SD card to be inserted to run (though this could easily be changed to use DATA statements in the program). The SD card also allows you to store your character any time you enter one of the "safe" castles at each end of the valley.

I have also placed a newer copy of the VALLEY.BAS program on the web site - my son came in and started playing it and found a silly bug at the beginning where I did not name the character type correctly!

I have also updated the documentation PDF file with the complete article from Computing Today (back in 1982!).

Enjoy!!

Edit....

I just uploaded the initialisation program again as it had a bug - When I copied the 3 individual programs into one program, I did not check that my DIM'd variables were not reused - so a runtime error resulted....
Edited by seco61 2011-08-24

Regards

Gerard (vk3cg/vk3grs)
 
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024