News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu
avatar_AMSDOS

Hisoft Pascal 4T

Started by AMSDOS, 11:33, 25 August 12

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

AMSDOS



I've been having a look at this other Pascal Compiler which works under AMSDOS:

Hisoft Pascal 4T - CPCWiki


and have generated a couple of small programs (nothing ground breaking), which handle Data Input/Output.


I had some other small BASIC files on this disk too, cause I was testing out How the data from the file generated could be managed in Hisoft Pascal 4T, though none of my attempts from those files (which were binary and ASCII based) would work in that environment.


LOADAT.BIN is the executable (7k) file I created using this compiler, though when I used the compiler to generate this program, it named it after my program file, fortunately the Source Code was stored as a Backup, though it just meant renaming everything back to what it was. (EDIT:  I think this is due to the fact this compiler was written to work on Tape on a 464, though will work on a 6128 and Disc Basic Systems).


Unfortunately to view the Pascal Source Code you will need that Compiler (I think), loading it from that compiler is no big deal:


G,,<filename.ext> or G,,loadat.pas


Listing the program from the compiler is merely 'L' followed by [ENTER] at the prompt.


The other program I made is "savedata.pas", which simply asks for some numbers (I think they can be letters or words though), 10 in all and then it stores them into the "DATA.DAT" file.


Unfortunately due to the nature of the way this Pascal Compiler handles the file I had to use it's built-in Loading and Saving facilities for me to load and Display the output, which has resulted in a file which is a bit of an unknown. My first impression was it was a Binary File cause their routines "TIN" & "TOUT" asks for a Start Origin for the file and TOUT asks for the Length of the file.
The Good News it works so the corresponding sections of the Array I setup reflect the values which are supposed to be in them.


The reason I had to setup these programs is because it won't let me do conventional Constant Arrays with Data in them, there maybe another way apart from going through every array position and giving it a value, though this seems to have worked even though I'm loading another file.


The Generated file "LOADAT.BIN" is a bit of a oddity, it's an executable file which begins @ &40h & seems to comprise of a bit of the terminal, so when the program is about to exit it will ask if you want to run it again, prompting anything but 'Y' will reset the computer.


People will probably noticed that I've got some other Pascal program on the attached disk image which is what I'm slowly working towards, it's a bit of a test though cause I'm converting this from my Turbo Pascal BOUNCY.PAS program.
* Using the old Amstrad Languages :D * And create my own ;)
* Incorporating the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

AMSDOS

Well it hasn't taken all that long for me to sort out that other program, there were a few horrible bugs in it though (horrible meaning obvious). It's slightly different from the one on my website, though the result appears the same (apart from the exit approach), it still exits on [ESC] there was a poke somewhere which could disable that.


It appears to run at the same pace as the Turbo Pascal version, though I haven't looked at it in ages.
* Using the old Amstrad Languages :D * And create my own ;)
* Incorporating the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

AMSDOS

#2
This my latest update from the last program, I've revised my routine which plots an 8x8 image to the screen and made it an RSX  , which I can access from my Pascal program. Seems to have worked well, I'm grateful someone has put the Manual on CPCWiki cause I would of been stumped without it.  :D  Oh and yeah, the program with my revisions put in place, has doubled the speed of the program.  ;D


[attachimg=2]
* Using the old Amstrad Languages :D * And create my own ;)
* Incorporating the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

Gryzor

So, just asking, what do these programs do?

AMSDOS

Quote from: Gryzor on 12:42, 13 September 12
So, just asking, what do these programs do?


Oh I didn't want to bore you with the details about the first routine


Spoiler: ShowHide
but in case your wondering, it's two programs "savedata.pas" I think I called it and "loadat.pas". "savedata.pas" has been quite useful (when I've been using it for the other 2 programs). From that program I can enter a series of numbers and once it's collected 10 numbers in a series in that case, a data file is saved. "loadat.pas" or the compiled program "loadat.bin" which you simply run from BASIC will display the numbers saved from the saved file (which is far from exciting).


The reason I had to things like this was because unlike Turbo Pascal which allows for constant array's, Hisoft Pascal only supports the declaration of array's, though it won't recognise constant array's. The equivalent in Locomotive BASIC is through 'DATA' statements, so things like Machine Code, Musical Tune Data, or simply Sprite Data or Colour Data can be processed within the program.
By using the TIN & TOUT Procedures which are available in Hisoft Pascal, it's possible to read in DATA from (in this case) another files into an array.



The second program is more interesting, though still only a simple Graphical Bouncing Ball Bouncing around a Window Box. This program is on my Turbo Pascal website, though have modified it to work with Hisoft Pascal.


Spoiler: ShowHide
I modified the "savedata.pas" program so I could enter the data I would need to draw the "ball" sprite, once that file is created the rest of the program "bouncy.pas" relies on Pascal to draw that ball and for each segment to make it look as if it's moving, it gets drawn over again & again, though because I'm using Pascal source to draw this, it takes some time to get from one spot to another. The only interesting thing from this program is the drawing routine I used to draw the ball, is pretty much the same as what I had in Turbo Pascal.



The Third program I made addresses the issues with the second program, but in this case I've incorporated a Machine Code RSX which draws up the Ball Sprite. From Hisoft Pascal I can use an External procedure which allows you to call that RSX and from that benefit more from the Machine Code.


Spoiler: ShowHide
To do that meant typing a lot of Decimal M/C data into my modified "savedata.pas" program, to make it possible the easiest way to get this done without any errors in it was to Output the file to the printer and using numbers along the way as a guide and from my "savedata.pas" program have the numbers there (but not save them to the datafile), so they would be used as a guide, the only thing which would go into it would be the Decimal Numbers to represent the Display routine and the Ball Sprite itself. Once that was all done it has produced a small example of how to Integrating Machine Code with the Pascal bits. There are other ways of incorporating M/C into the Pascal, though given the number of values the RSX needs to do what it needs to do, it seemed easier this way.



On the Disk Images there should be some Binary Files which are around 7k or 8k, which are the compiled programs which can run from BASIC, the reason why their so large is it appears a large library file is there to be able to run the program.
* Using the old Amstrad Languages :D * And create my own ;)
* Incorporating the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

Devilmarkus

Quote from: Gryzor on 12:42, 13 September 12
So, just asking, what do these programs do?

RUN"BOUNCY2" and watch ;)
When you put your ear on a hot stove, you can smell how stupid you are ...

Amstrad CPC games in your webbrowser

JavaCPC Desktop Full Release

Devilmarkus

Simple BASIC listing:
10 MODE 1
20 PRINT CHR$(23);CHR$(0)
30 PLOT 200,100,2:DRAW 440,100:DRAW 440,300:DRAW 200,300:DRAW 200,100
40 PRINT CHR$(23);CHR$(1)
50 SYMBOL 250,&X0,&X111100,&X1000010,&X1000010,&X1000010,&X1000010,&X111100
60 SYMBOL 251,0,0,&X111100,&X111100,&X111100,&X111100
70 TAG:x=320:y=200
80 xs=2:ys=2
90 x=x+xs:y=y+ys:GOSUB 150:CALL &BD19:GOSUB 150
100 IF TEST(x,y-16)=2 THEN ys=2
110 IF TEST(x,y+2)=2 THEN ys=-2
120 IF TEST(x-2,y)=2 THEN xs=2
130 IF TEST(x+16,y)=2 THEN xs=-2
140 GOTO 90
150 PLOT -5,-5,1:MOVE x,y:PRINT CHR$(250);:PLOT -5,-5,3:MOVE x,y:PRINT CHR$(251);:RETURN


Is there a way to do the same in BASIC without flickering? ;)
When you put your ear on a hot stove, you can smell how stupid you are ...

Amstrad CPC games in your webbrowser

JavaCPC Desktop Full Release

AMSDOS

Quote from: Devilmarkus on 14:11, 13 September 12
Simple BASIC listing:
10 MODE 1
20 PRINT CHR$(23);CHR$(0)
30 PLOT 200,100,2:DRAW 440,100:DRAW 440,300:DRAW 200,300:DRAW 200,100
40 PRINT CHR$(23);CHR$(1)
50 SYMBOL 250,&X0,&X111100,&X1000010,&X1000010,&X1000010,&X1000010,&X111100
60 SYMBOL 251,0,0,&X111100,&X111100,&X111100,&X111100
70 TAG:x=320:y=200
80 xs=2:ys=2
90 x=x+xs:y=y+ys:GOSUB 150:CALL &BD19:GOSUB 150
100 IF TEST(x,y-16)=2 THEN ys=2
110 IF TEST(x,y+2)=2 THEN ys=-2
120 IF TEST(x-2,y)=2 THEN xs=2
130 IF TEST(x+16,y)=2 THEN xs=-2
140 GOTO 90
150 PLOT -5,-5,1:MOVE x,y:PRINT CHR$(250);:PLOT -5,-5,3:MOVE x,y:PRINT CHR$(251);:RETURN


Is there a way to do the same in BASIC without flickering? ;)


Having more CALL &BD19's will slow the flicker rate down a little bit, though it will start to slow things down a bit. Nice idea though defining the Ball as two defined symbols and using XOR Mode to combine the two. I think part of the problem is the XOR Mode unfortunately, because anything which uses it has to be constantly refreshed before it gets moved.  :(  Applying something like that from Assembly and using Firmware would accelerate the progress, the flicker would still be evident, though less obvious or distracting.


I kind of wonder how the flicker would be though if you had the CALL &BD19 before GOSUB 150 in line 90 and having another line between 130 & 140 which "CALL &BD19" & "GOSUB 150" to remove the XORed image.
Also you haven't defined any of your variables - "x,y, xs or ys" are all Integer, though BASIC will just assume their Real numbers, "defint a-z" fixes that or "%" after your variables - "x%=320","y%=200"," xs%=2" or "ys%=2"  might help.
* Using the old Amstrad Languages :D * And create my own ;)
* Incorporating the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

AMSDOS

Quote from: Devilmarkus on 14:11, 13 September 12
Is there a way to do the same in BASIC without flickering? ;)


Wasn't sure if you had an answer for that flickering problem. I just remembered over in my other thread I had a small BASIC program which was moving a Square around using "ORIGIN", this also had some flickering associated with it though.


The only thing I've seen bounce around in BASIC which Nich typed in was this Blitter program:
Amstrad Action July 1986 Type-Ins - CPCWiki
In that situation the program is using the illiusion of making the background look still with the Ball moving around and is using some OUT statements for the effect.  :o


I've had a couple of ideas studying your BASIC code (with the TEST checks) and some other stuff from another BASIC game and I thought it would be interesting to test the "EVERY" instruction which is available in Hisoft Pascal.
* Using the old Amstrad Languages :D * And create my own ;)
* Incorporating the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

Devilmarkus

Yeah I know the Blitter-demo.
They move the screen-ram by using OUT functions.
So everything moves: Background, ball, everything ;)

But is it possible to animate small sprites in BASIC without flickering?
When you put your ear on a hot stove, you can smell how stupid you are ...

Amstrad CPC games in your webbrowser

JavaCPC Desktop Full Release

SyX

OT: CP/M User, you have solved a mystery that i had since my childhood. This "blitter" program was published in the spanish "Amstrad User", but i always have known that was copied from other place, because in 1986 the number of Amiga users in Spain was practically 0 :)

AMSDOS

#11
Quote from: Devilmarkus on 11:29, 09 October 12
So everything moves: Background, ball, everything ;)


Yep, except it's setup in such a way that it looks like the Ball only moves.  ;D

Quote
But is it possible to animate small sprites in BASIC without flickering?


Haven't been able to demonstrate it, though I have define a 6x6 shape and move it around the screen without flicker, so perhaps it's possible to rig up something like what you've done, unsure what would happen if you tried to make the image larger, more flicker perhaps?



Quote from: SyX on 14:35, 09 October 12
OT:
CP/M User, you have solved a mystery that i had since my childhood. This "blitter" program was published in the spanish "Amstrad User", but i always have known that was copied from other place, because in 1986 the number of Amiga users in Spain was practically 0 :)

I recently notice the same sort of thing happening in our own Australian Amstrad Magazine which had some Type-ins from Amstrad 464 User for example and later on they had cheats (from Amstrad Action), I think it was all legitimate though and Type-ins were acknowledged to their respected authors.
* Using the old Amstrad Languages :D * And create my own ;)
* Incorporating the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

AMSDOS

This is my effort which is blinking in the middle.  ;D


10 MODE 1

20 SYMBOL 255,0,60,66,66,66,66,60,0
30 SYMBOL 254,0,0,60,60,60,60,0,0
40 x=0:xdir=2:y=100:ydir=2
50 WHILE 1
60 x=x+xdir:y=y+ydir:PRINT CHR$(23);CHR$(0);:TAG:PLOT -2,-2,1:MOVE x,y:CALL &BD19:PRINT CHR$(255);:TAGOFF
70 PRINT CHR$(23);CHR$(1);:TAG:PLOT -2,-2,3:MOVE x,y:CALL &BD19:PRINT CHR$(254);:TAGOFF
80 IF x=100 THEN xdir=-2
90 IF x=0 THEN xdir=2
100 IF y=300 THEN ydir=-2
110 IF y=16 THEN ydir=2
120 WEND
* Using the old Amstrad Languages :D * And create my own ;)
* Incorporating the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

HAL6128

my two attempts... I think it's not possible in BASIC without flickering at all...


10 MODE 1
20 ORIGIN 0,0
30 DEFINT a-z
40 transoff$=CHR$(23)+CHR$(0)
50 transon$=CHR$(23)+CHR$(1)
60 GRAPHICS PEN 2:MOVE 200,100:DRAW 440,100:DRAW 440,300:DRAW 200,300:DRAW 200,100
70 PRINT transon$
80 SYMBOL 250,&X0,&X111100,&X1000010,&X1000010,&X1000010,&X1000010,&X111100
90 SYMBOL 251,0,0,&X111100,&X111100,&X111100,&X111100
95 s1$=CHR$(250)
96 s2$=CHR$(251)
100 TAG:x=320:y=200:dxp=2:dyp=2:dxn=-2:dyn=-2:yo=300:yu=114:xl=200:xr=426
130 dy=dyp:dx=dxp
135 GRAPHICS PEN 1
140 WHILE 1
150 MOVE x,y:PRINT s1$;:MOVE x,y:GRAPHICS PEN 3:CALL &BD19:PRINT s2$;
160 IF y>=yo THEN dy=dyn
170 IF y<=yu THEN dy=dyp
180 IF x<=xl THEN dx=dxp
190 IF x>=xr THEN dx=dxn
200 x=x+dx:y=y+dy
210 MOVE x-dx,y-dy:CALL &BD19:PRINT s2$;:MOVE x-dx,y-dy:GRAPHICS PEN 1:PRINT s1$;
220 WEND


here with a changing of screen base address and out commands

5 MEMORY &3FFF
10 MODE 1
20 ORIGIN 0,0
30 DEFINT a-z
40 transoff$=CHR$(23)+CHR$(0)
50 transon$=CHR$(23)+CHR$(1)
65 WINDOW 12,28,6,19
70 PRINT transon$
80 SYMBOL 250,&X0,&X111100,&X1000010,&X1000010,&X1000010,&X1000010,&X111100
90 SYMBOL 251,0,0,&X111100,&X111100,&X111100,&X111100
95 s1$=CHR$(250)
96 s2$=CHR$(251)
100 TAG:x=320:y=200:dxp=2:dyp=2:dxn=-2:dyn=-2:yo=300:yu=114:xl=200:xr=426
105 bs=&B7C6:b=&40:p1=&BCFF:p2=&BDFF
130 dy=dyp:dx=dxp
140 WHILE 1
145 b=&100-b:POKE bs,b:CLS
150 MOVE x,y:GRAPHICS PEN 1:PRINT s1$;:MOVE x,y:GRAPHICS PEN 3:PRINT s2$;
160 IF y>=yo THEN dy=dyn
170 IF y<=yu THEN dy=dyp
180 IF x<=xl THEN dx=dxp
190 IF x>=xr THEN dx=dxn
200 x=x+dx:y=y+dy
210 OUT p1,12:OUT p2,b\4
220 WEND
...proudly supported Schnapps Demo, Pentomino and NQ-Music-Disc with GFX

AMSDOS

I'm intrigued with that second example, though I'm not totally sure how it works even though I can see the final result on a 6128. I tried altering the program to work on a 464, though I couldn't get the same result, I even changed "bs=&B7C6" to read "bs=&B1CB", but had no luck cause it looks like it works slightly differently on a 464.  :o
* Using the old Amstrad Languages :D * And create my own ;)
* Incorporating the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

AMSDOS

Okay I understand that 2nd program better now, this will work on a 464:




10 MEMORY &3FFF
20 MODE 1
30 ORIGIN 0,0
40 DEFINT a-z
50 transoff$=CHR$(23)+CHR$(0)
60 transon$=CHR$(23)+CHR$(1)
70 WINDOW 12,28,6,19
80 PRINT transon$
90 SYMBOL 250,0,60,66,66,66,60
100 SYMBOL 251,0,0,60,60,60,0
110 x=320:y=200:dxp=2:dyp=2:dxn=-2:dyn=-2:yo=300:yu=114:xl=200:xr=426
120 bs=&B1CB:b=&40:p1=&BCFF:p2=&BDFF
130 dy=dyp:dx=dxp
140 WHILE 1
150 b=&100-b:POKE bs,b:CLS
160 TAG:PLOT -2,-2,1:MOVE x,y:PRINT CHR$(250);:PLOT -2,-2,3:MOVE x,y:PRINT CHR$(251);:TAGOFF
170 IF y>=yo THEN dy=dyn
180 IF y<=yu THEN dy=dyp
190 IF x<=xl THEN dx=dxp
200 IF x>=xr THEN dx=dxn
210 x=x+dx:y=y+dy
220 OUT p1,12:OUT p2,b\4
230 WEND



"tag" seems to work a little bit differently on a 464 cause the formatted control codes (for XOR I think) was returning unwanted rubbish and messing up the screen. Simply restricting "tag"/"tagoff" to that line resolves that problem.
* Using the old Amstrad Languages :D * And create my own ;)
* Incorporating the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

HAL6128

Normally it's a semicolons task (after a print command) to surpress printing control codes while tag is switched on. Never had programed on BASIC 1.0 so far ...interesting.
...proudly supported Schnapps Demo, Pentomino and NQ-Music-Disc with GFX

AMSDOS

Quote from: HAL 6128 on 19:44, 12 October 12
Normally it's a semicolons task (after a print command) to surpress printing control codes while tag is switched on. Never had programed on BASIC 1.0 so far ...interesting.


Yep the semicolons are working fine, the culprit in this case is "CLS". In BASIC 1.0 if "TAG" is enabled and "CLS" is carried out, it will return the control code for Clear Screen -> "PRINT CHR$(12);"
In BASIC 1.1, even if "TAG" is enabled and Clear Screen is applied, then the Screen will be cleared. In an odd way BASIC 1.0 is sort of correct because "CLS" is applying "PRINT CHR$(12);".
* Using the old Amstrad Languages :D * And create my own ;)
* Incorporating the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

AMSDOS

Wasn't sure what was happening with the Wiki at the moment, but if this looks interesting I'll stick this on it. Let me know.


In this example I will be using my own little Assembly routine which plots an image to screen:




   org &8000


;; Conditions of Entry Usage - |PLOTIMAGE,<xpos>,<ypos>,<address of image>
;;                         e.g |PLOTIMAGE,100,200,&80A5


   ld hl,workspace
   ld bc,table
   call &bcd1
   ret
.table   defw table2
   jp beginplot


.workspace
   defb 0,0,0,0
.table2
   defb 'PLOTIMAG'
   defb 'E'+&80
   defb 0   
   
.beginplot
   ld l,(ix+00)            ;; Address of Data Colour
   ld h,(ix+01)
   ld (addrcolour),hl         ;; Place this into Address Colour


   ld l,(ix+04)
   ld h,(ix+05)
   ld (xpos),hl            ;; Place co-ordinates of Image into Xpos
   ld (resxpos),hl


   ld l,(ix+02)
   ld h,(ix+03)
   ld (ypos),hl            ;; Place co-ordinates of Images into Ypos
   
.plotimg   
   ld hl,(addrcolour)         ;; Place Contents of Address Colour into HL
   ld a,(hl)            ;; Put Contents of HL into A
   call do_colour   


   ld de,(xpos)            ;; XPOS data into DE
   ld hl,(ypos)            ;; YPOS data into HL
   call &bbea            ;; GRA ABSOLUTE PLOT


   ld hl,(xpos)            ;; Obtain Contents of XPOS
   inc hl               ;; Is 16bit Value so Increment 
   inc hl               ;; Twice
   ld (xpos),hl            ;; Place next value into XPOS
   
   ld a,(fcount)            ;; First Counter Position into A
   inc a               ;; Increment this     
   ld (fcount),a            ;; Put New Value into First Count Position
   ld b,a               ;; Put this value into B


   ld a,(xlcount)            ;; Place First Counter Marker into A


   cp b               ;; Has value of B reached A value
   jr nz,plotimg            ;; If No Loop back, otherwise continue


   ld a,(fcount)            ;; At this stage fcount equals 8
   xor a               ;; This will make it 0 again
   ld (fcount),a            ;; And put that value into fcount


   ld hl,(ypos)            ;; YPOS of data can now be Incremented
   dec hl               ;; Again 16bit Value means Incrementing
   dec hl               ;; it Twice
   ld (ypos),hl            ;; And put that value into YPOS.


   ld hl,(resxpos)            ;; Need to restore the value of XPOS.
   ld (xpos),hl            ;; New Value goes into XPOS.
   
   ld a,(scount)            ;; Second counter goes into A
   inc a               ;; Increase it.
   ld (scount),a            ;; Place back into Second Counter
   ld b,a               ;; Put value of Second counter into B


   ld a,(ylcount)            ;; Place Y-counting position into A


   cp b               ;; Compare A to value of B
   jr nz,plotimg            ;; If reached exit, otherwise return
   
   ld a,0               ;; \
   ld hl,fcount            ;; \\
   ld (hl),a            ;; Returns loop values back to 0 (important)
   ld hl,scount            ;; //
   ld (hl),a            ;; /
   
   ret               ;; Program exits here.


.do_colour
     call &bbde            ;; GRA SET PEN - A = Pen Colour
     ld hl,(addrcolour)         ;; Take address of address colour
     inc hl               ;; Increment it by 1
     ld (addrcolour),hl         ;; Put this value into Address Colour
     ret               ;; Return to Main Loop Routine.
   
.fcount defb 0
.scount defb 0
.xlcount   
   defb 8               ;; Number of times to loop across.
.ylcount
   defb 8               ;; Number of times to loop down
.xpos   defw 0               ;; Left Position the image
.ypos   defw 0               ;; Bottom Position of the image.
.resxpos
   defw 0               ;; This is used to Restore Xpos.
.data_colour
    defb 0,0,0,0,0,0,0,0
    defb 0,0,1,1,1,1,0,0
    defb 0,1,3,3,3,3,1,0
    defb 0,1,3,3,3,3,1,0
    defb 0,1,3,3,3,3,1,0
    defb 0,1,3,3,3,3,1,0
    defb 0,0,1,1,1,1,0,0
    defb 0,0,0,0,0,0,0,0


.addrcolour
    defw 0               ;; This points to the address position
                  ;; within the data colour.



It's not the fastest thing around, and certainly other proper Sprite Routines could be used, to show how to Incorporate other RSX routines into Hisoft Pascal. :)


I've been using Winape and for the Assembly Examples I've been using Winape Assembler, though my routines should work with Maxam too.


Once it's been Assembled into Memory the next phase is to disassemble it in BASIC. Because I'm using Winape, I can print the code to printer file:



for num=0 to 231:print#8,num;"    ";peek(32768+num):next num



Unfortunately, I have to do this to get the code into a file that Hisoft Pascal 4T can read, though in the source, I have numbered the values for reference, so it makes it easier to key in each opcode.


It should produce something like this (as long as the program is in memory):




0    33
1    15
2    128
3    1
4    10
5    128
6    205
7    209
8    188
9    201
10    19
11    128
12    195
13    29
14    128
15    0
16    0
17    0
18    0
19    80
20    76
21    79
22    84
23    73
24    77
25    65
26    71
27    197
28    0
29    221
30    110
31    0
32    221
33    102
34    1
35    34
36    229
37    128
38    221
39    110
40    4
41    221
42    102
43    5
44    34
45    159
46    128
47    34
48    163
49    128
50    221
51    110
52    2
53    221
54    102
55    3
56    34
57    161
58    128
59    42
60    229
61    128
62    126
63    205
64    144
65    128
66    237
67    91
68    159
69    128
70    42
71    161
72    128
73    205
74    234
75    187
76    42
77    159
78    128
79    35
80    35
81    34
82    159
83    128
84    58
85    155
86    128
87    60
88    50
89    155
90    128
91    71
92    58
93    157
94    128
95    184
96    32
97    217
98    58
99    155
100    128
101    175
102    50
103    155
104    128
105    42
106    161
107    128
108    43
109    43
110    34
111    161
112    128
113    42
114    163
115    128
116    34
117    159
118    128
119    58
120    156
121    128
122    60
123    50
124    156
125    128
126    71
127    58
128    158
129    128
130    184
131    32
132    182
133    62
134    0
135    33
136    155
137    128
138    119
139    33
140    156
141    128
142    119
143    201
144    205
145    222
146    187
147    42
148    229
149    128
150    35
151    34
152    229
153    128
154    201
155    0
156    0
157    8
158    8
159    0
160    0
161    0
162    0
163    0
164    0
165    0
166    0
167    0
168    0
169    0
170    0
171    0
172    0
173    0
174    0
175    1
176    1
177    1
178    1
179    0
180    0
181    0
182    1
183    3
184    3
185    3
186    3
187    1
188    0
189    0
190    1
191    3
192    3
193    3
194    3
195    1
196    0
197    0
198    1
199    3
200    3
201    3
202    3
203    1
204    0
205    0
206    1
207    3
208    3
209    3
210    3
211    1
212    0
213    0
214    0
215    1
216    1
217    1
218    1
219    0
220    0
221    0
222    0
223    0
224    0
225    0
226    0
227    0
228    0
229    0
230    0
231    0




For this example and for it to work in the following program which was written in Hisoft Pascal, the code has to be in decimal.




   10 PROGRAM SaveData2;
   20
   30 VAR
   40   data : ARRAY[0..231] OF INTEGER;
   50   count : integer;
   60
   70 BEGIN
   80 WRITELN('Enter Data:');
   90 FOR count:=0 TO 231 DO
  100 BEGIN
  110   WRITE(count);
  120   write(' : ');
  130   read(data[count]);
  140 END;
  150
  160 writeln('Entering Complete Saving Data.');
  170 TOUT('SPREBALL.DAT',ADDR(data),SIZE(data));
  180 END.



In order to use other routines, modifications would have to be made to the size of the array which is 232 bytes for my example along with adjustments to the size of the loop which has been custom made for handling my routine. Running this program in Hisoft Pascal it will display a counter along with a spot to enter the appropriate value, once it's reach the end with all the values entered it will save the file using it's own TOUT command with the address pointing to where the  data array is and the size of it.


And now the final program with Demo. When running Hisoft Pascal, it will prompt you where to set the RAM Top, in this example I say &7FFF because that's where my routine will be going. I've thrown in a number of procedures which is what Hisoft Pascal 4T encourages which was done to help minimise the size of the code.




   10 PROGRAM BOUNCY;
   20 { *** Written IN Hisoft Pascal 4T *** }
   30 { ***        Public Domain        *** }
   40 { *** Save PROGRAM BEFORE Running *** }
   50 { *** Now Using External M/C FOR  *** }
   60 { ***       Sprite Routine!       *** }
   70 
   80 VAR
   90   Prog : ARRAY [0..231] OF integer;
  100   Xpos, Xdir, Ypos, Ydir,
  110   Width, Length : integer;
  120   Loop : Boolean;
  130 
  140 PROCEDURE LoadSprite;
  150  VAR
  160    loop : integer;
  170
  180  BEGIN
  190    tin('spreball.dat',addr(Prog));
  200    FOR loop:=0 TO 231 DO
  210      poke(#8000+loop,prog[loop]);
  220    user(#8000);
  230  END;
  240
  250 Procedure mode(mo:integer);
  260  begin
  270    RA:=chr(mo);
  280    USER(#BC0E);
  290  end;
  300
  310 PROCEDURE Ink(no,col : integer);
  320  BEGIN
  330   RA:=chr(no);
  340   RBC:=col;
  350   USER(#BC32);
  360  END;
  370
  380 Procedure Draw(Xpos, Ypos : Integer);
  390  begin
  400    RDE:=Xpos;
  410    RHL:=Ypos;
  420    USER(#BBF6);
  430  end;
  440 
  450 Procedure Move(Xpos, Ypos : Integer);
  460  begin
  470    RDE:=Xpos;
  480    RHL:=Ypos;
  490    USER(#BBC0);
  500  end;
  510
  520 Procedure resetcolor;
  530  begin
  540    USER(#BC02);
  550  end;
  560
  570 Procedure grapen(col:integer);
  580  begin
  590    RA:=chr(col);
  600    USER(#BBDE);
  610  end;
  620
  630 Procedure PlotPoint(xpos,ypos:integer);
  640  begin
  650    RDE:=xpos;
  660    RHL:=ypos;
  670    USER(#BBEA);
  680  end;
  690
  700 Procedure Frame;
  710  begin
  720    USER(#BD19);
  730  end;
  740
  750 { Main Procedures }
  760
  770 PROCEDURE PlotImage(Xpos, Ypos, Adr : integer);
  780 BEGIN
  790   external('plotimage',xpos,ypos,adr);
  800 END;
  810
  820 Procedure DrawBox;
  830  Begin
  840   Grapen(2);
  850   Move(200,300);
  860   Draw(470,300);
  870   Draw(470,100);
  880   Draw(200,100);
  890   Draw(200,300);
  900  End;
  910
  920 begin { Main Routine }
  930  ResetColor;
  940   LoadSprite;
  950  Mode(1);
  960  ink(0,#0000);
  970  ink(1,#0202);
  980  ink(3,#0b0b);
  990  DrawBox;
1000   Loop:=True;
1010   Xpos:=205;
1020   Ypos:=281;
1030   Xdir:=1;
1040   Ydir:=-1;
1050  REPEAT
1060    Xpos:=Xpos+Xdir;
1070    Ypos:=Ypos+Ydir;
1080    Frame;
1090    Frame;
1100    PlotImage(Xpos,Ypos,#80A5);
1110   Case Xpos of
1120    454 : Xdir:=-1;
1130    202 : Xdir:=1
1140   end;
1150   Case Ypos of
1160    298 : Ydir:=-1;
1170    118 : Ydir:=1
1180   end;
1190  UNTIL Loop=False;
1200 { This is an Infinate Loop }
1210 END.



In relation to the M/C I've produced, I'm using the LoadSprite procedure to load the code using TIN. Because I was using a Tape Version of Hisoft Pascal 4T <- presumibly 4T means 4 Tape :) if the filename was less than 8 Characters then spaces need to be inserted, though because my filename is 8 characters along with the 4 for the extension they aren't shown. A shorter filename would have spaces to bring it upto the 8 characters and then followed by the ".EXT" bit.
In this example you'll noticed I've called the data array from the last program -> "prog" instead though still with the same size. What TIN does is load the contents into the Array - prog, but then I need to Poke those contents into Memory for where it should go, which is what the loop after that is doing and then it does a USER(#8000) which is a "CALL &8000" in BASIC to activate the RSX and from there I can use that RSX in my own program.


In my example what's happened is I've setup a routine which plots a specific image, the RSX has parameters associated with it which ask what the XPOS, YPOS and the address of the Image.
The address of the Image in my case is where I setup ".data_colour" in my Assembly code, so I've got that address from when I assembled the code.


In my final code these lines:




770 PROCEDURE PlotImage(Xpos, Ypos, Adr : integer);
  780 BEGIN
  790   external('plotimage',xpos,ypos,adr);
  800 END;



deal with the setting up that Procedure which I've called in line 1100 to display the correct image. The important thing to note in Hisoft Pascal is Hexadecimal numbers being with the hash "#" otherwise the compiler it spits the dummy.


Well after all that I hope this encourages those not to do it! :D
* Using the old Amstrad Languages :D * And create my own ;)
* Incorporating the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

AMSDOS

#19

I've been trying to create some routines which generate some random numbers though the random function seems to be nearly useless. :( For instance to get a random number out of the thing - "num:=random(0)" has to be used which generates a number between 0..32767, but all I want is a number between 0 & 20, so then I have to produce something which gets me something between those values.




   10 PROGRAM RanNumbers;
   20
   30 VAR num : integer;
   40     num2 : integer;
   50     count : integer;
   60
   70 BEGIN
   80 num:=random(0);
   90 num:=trunc(num/7/7/7);
  100 IF num>50 THEN num:=trunc(num/7);
  110 IF num>20 THEN num:=trunc(num/num);
  120 writeln(num);
  130 END.



This was my first routine which is really a rough routine - 7 seemed to be the best number to use given nothing goes into it, though if the number falls between 21 & 50, then it gets divided by itself to give you 1 - bizarre.






   10 PROGRAM RanNumbers2;
   20
   30 VAR num : integer;
   40     num2 : integer;
   50     count : integer;
   60
   70 BEGIN
   71 page;
   80 num:=random(0);
   90 writeln('First Number');
  100 writeln(num);
  110 num2:=random(0);
  120 writeln;
  130 writeln('Second Number');
  140 writeln(num2);
  150 writeln;
  160 IF num2>num THEN num:=num2-num ELSE num:=num-num2;
  170 writeln('Equals');
  180 writeln(num);
  190 writeln;
  200 IF num>1000 THEN num:=trunc(num/7);
  210 IF num>500 THEN num:=trunc(num/7);
  220 IF num>140 THEN num:=trunc(num/7);
  230 IF num>20 THEN num:=trunc(num/7);
  240 writeln('Final Result');
  250 writeln(num);
  260 END.



This second program is perhaps a bit better, though it has to do more to get to a final result. Two Random number seeds are setup, line 160 works out which number is larger and subtracts the larger number from the smaller number. After that if the number is still over 1000 is gets divided by 7 and so on if the number is larger than 500, 140 & 20. The trouble with this routine is you cannot get anything smaller than 3 - maybe I should divide more than 7 - have it divide by 13 perhaps?


I might be better if I use an assembly routine to generate a random number, any thoughts? It's just annoying that something effective can be done in BASIC with n=(rnd*20) to get a number within a certain range.
* Using the old Amstrad Languages :D * And create my own ;)
* Incorporating the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

AMSDOS

#20
Anyone who remembers the ol' Amstrad Manual will probably know the Circle program where the manual gives you the opportunity to play around with the different drawing aspects of it, etc.


Well I've taken the original and made it for this Pascal:


10 PROGRAM circle;

   20 (*$c-*)
   30
   40 VAR loop : integer;
   50
   60 PROCEDURE move(x,y : integer);
   70 BEGIN
   80   rde:=x;
   90   rhl:=y;
  100   user(#bbc0);
  110 END;
  120
  130 PROCEDURE draw(x,y : integer);
  140 BEGIN
  150   rde:=x;
  160   rhl:=y;
  170   user(#bbf6);
  180 END;
  190
  200 PROCEDURE mode(a : char);
  210 BEGIN
  220   ra:=a;
  230   user(#bc0e);
  240 END;
  250
  260 FUNCTION degtorad(val : integer) : real;
  270 VAR num1 : real;
  280 BEGIN
  290   num1:=3.14159/180;
  300   degtorad:=num1*val;
  310 END;
  320
  330 BEGIN
  340   mode(chr(1));
  350   loop:=0;
  360   REPEAT
  370     move(320,200);
  380 draw(round(320+190*cos(degtorad(loop))),round(200+190*sin(degtorad(loop))));
  390     loop:=loop+1;
  400   UNTIL loop=361;
  410 END.



The program blows out a bit because I need to setup MODE, MOVE & DRAW (things which BASIC takes for granted), just to use them for this routine. The other thing the original program does is calculate everything in DEGrees. You can draw it in RADians, though the output is obviously different (if output of the original program is critical), and yes there is Firmware which allows you to change from RADians to DEGrees and visa-versa, which works in BASIC, however this is part of the Maths Firmware which is a part of where Addresses begin to change between 464 & 664/6128, plus on top of that the Pascal routines COS() & SIN() for which the Degrees normally takes effect in, doesn't work if the machine is setup in DEGrees, meaning the result will always be in RADians. So the only other way I know how to get the result looking like DEGrees is to convert it to a result in RADians, but when a COS() or SIN() is applied the result there will be similar to something which is in Degrees.


[attachimg=2]
* Using the old Amstrad Languages :D * And create my own ;)
* Incorporating the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

AMSDOS

#21
Further to the Random Number stuff I had earlier, I've been plugging along to get some external M/C 8bit Random number routines working. After a lot of mucking about, and realising I need to load my External File into the Internal Array and then poke it to memory and then call it at Runtime so they work correctly, I've managed to get something which Produces a Random Seed (0-255) & a hundred or so random numbers between 0 & 19. Because Hisoft Pascal is kind of like traditional Pascal, it doesn't recognise the "Byte" type, so I'm being a rebel here and am using "Char" type, which is more or less the same, except in some circumstances it needs chr() & ord() in order to pass a value as a character or return an ordinal value. Not sure if it's a good thing since chr() & ord() use memory, the alternative is to make it an integer which uses 2 bytes instead of 1, my M/C Routines though are only using 1 byte to return a Seed & a Random Result, but in this example I've used peek to return the value back to the variable.


Earlier I tried to make an internal routine using Inline M/C, though I'm not sure what's wrong with my Random routine, the advantage of that would be I wouldn't need to worry about loading a RSX based Library all the time, and I could just throw in the appropriate bit of code rather than having to compile different RSX libraries all the time.


[attachimg=2]
* Using the old Amstrad Languages :D * And create my own ;)
* Incorporating the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

ralferoo

Quote from: SyX on 14:35, 09 October 12
This "blitter" program ... the number of Amiga users in Spain was practically 0 :)
Although the Amiga made the term blitter popular, it was actually in common use before that coming from at least Xerox in 1975.

In Amiga circles, it always accepted that it comes from "block image transfer", but was originally known as BITBLT for "bitwise block transfer" before morphing into "bit blit" and then just "blit". The original term BLT came from the PDP-10 from the 60s which had an instruction BLT for block transfers.

There's a bit more info here: blit

SyX

Yes, of course, i learnt that kung-fu during the 90s :)

But if finding an amiga user in Spain in that year was impossible, getting somebody with knowledge about the Xerox Alto was an utopia, jejejeje.

Although i said more for the "boing" demo than the blitter term, another curiosity about this, it's the occurrences of the "boing" demo in other platforms, for example in the pause mode in the zx spectrum "Fat Worm blows a sparky" :)


AMSDOS

#24
Well I'm not really a mathematical person, but I've worked out a Function which will work out a range and generate random based Integer numbers within a specified range, which pretty much makes my earlier Pascal based Random Number examples redundant.  :(


The Good news is I've tested this function to the extent it seems to work, but I don't expect it to work if the range is set to 0 because you simply don't divide by 0:




   10 PROGRAM integernd;
   20
   30 VAR num1, loop : integer;
   40
   50 FUNCTION intrnd(range : integer) : integer;
   60 VAR seed, result : integer;
   70 BEGIN
   80   seed:=random(0);
   90   result:=round(maxint/range);
  100   intrnd:=round(seed/result);
  110 END;
  120
  130 BEGIN
  140   FOR loop:=0 TO 100 DO
  150   BEGIN
  160    num1:=intrnd(30);
  170    write(num1);
  180   END;
  190 END.



So the idea I had was if you took the largest Integer based number which is 32767 in this case, divide it by a range specified, it will work out how many times how many times that will go into 32767 to which that gets stored into result. The next part is getting a random number, which I've done by storing a random number into seed, the seed is then divided with the result to produce a number within the specified range specified. In my example line 160 uses the function which specifies a range between 0-30 and the output from line 170 will certainly correspond to that.


[attachimg=2]
* Using the old Amstrad Languages :D * And create my own ;)
* Incorporating the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

Powered by SMFPacks Menu Editor Mod