Table of Contents

ugBASIC User Manual

PURPOSE

SOURCE CODE

 Bm En(16):C#a0=4:C# a1 = 2:
 C# a2 = Sc Hg / 16
 C# a3 = ( Sc Hg - 16 )
 C# a4 = ( Sc Wd - 16 )
 C# a5 = (Sc Wd / a0)
 Di x(a0), y(a0), dx(a0), dy(a0), d(a0), m(a0)
 Gb x, y, f, dx, dy, d, m
 Gb a6, a7, a8, b9
 
 a6 = 16*8
 a7 = 16*2+6
 
 Gb b0, b1, bgb0
 Gb b3, bgb3
 
 Prcd b5
 
 	bgb0 := Nw Ims(a0,16,10)
 	bgb3 := Nw Im(8,10)
 	
 	Cl Bl
 	Ik GREY
 	Br 0,0 To 15,3
 	Ik Bu
 	Dr"L16R2U3L2R16L2D3L4U3L3D3"
 	b1 := Nw Im(16,4)
 	Ge Im b1 Fm 0, 0
 
 	Cl 
 	Ik GREY
 	Br 2,2 To 6,9
 	Ik Bu
 	Dr"BL1U8L1D8"
 	b3 := Nw Im(8,10)
 	Ge Im b3 Fm 0, 0
 
 	Cl
 	Ik Re
 	Ci 4,4,4
 	P#(4,4)
 	Ik Wht
 	Dr"BU2L1D1L1D1"
 	b0 := Nw Im(16,10)
 	Ge Im b0 Fm 0, 0
 	
 	Cl
 
 	i = 0
 	ty = 3
 	Rpt
 		tx = (i * a5) + a1
 		x(i) = tx
 		y(i) = ty
 		dx(i) = a1
 		dy(i) = 0
 		Ge Im bgb0 Fr i Fm tx, ty
 		INC i
 	Un i = a0
 	Fil d Wi 1
 	Fil m Wi 0
 	
 Ee Prcd
 
 Gb bx, by
 
 Prcd b6
 	bx = 0
 	i = 0: j = RND(255)
 	Rpt
 		If (j An 1) = 0 Th
 			Pu Im b1 At bx, by
 		Ei
 		j = j \ 2
 		Ad bx, 16
 		INC i
 	Un bx > a4
 Ee Prcd
 
 Prcd b6s
 	by = 16
 	Rpt
 		b6[]
 		Ad by, 16
 	Un by > a3
 Ee Prcd
 
 Pr Prcd c8
 	Rpt
 		Wt Wh [d]
 		[m] = 1
 		If Pt([x]+3,[y]+9) = Bl Th
 			[dy] = a1
 			[dx] = 0
 		El
 			[dy] = 0
 			If [dx] = 0 Th
 				If RND(100) > 50 Th
 					[dx] = a1
 				El
 					[dx] = -a1
 				Ei
 			Ei
 			If [x] >= a4 Th
 				[dx] = -[dx]
 			Eif [x] < a1 Th
 				[dx] = -[dx]
 			Eif Pt([x]+9,[y]+4) <> Bl Th
 				[dx] = -[dx]
 			El If Pt([x]-3,[y]+4) <> Bl Th
 				[dx] = -[dx]
 			Ei
 		Ei
 		[m] = 0
 		[d] = 1
 	Un [y] > Sc Hg	
 Ee Prcd
 
 Pr Prcd c9
 
 	Do
 		c0 = 0
 		i = a0-1
 		Rpt
 			If c0 < y(i) Th
 				c0 = y(i) + 15
 			Ei
 			DEC i
 		Un i < 0
 		Wh Rst Ln < c0
 		We
 		FORBID
 		If a6 <> a8 OR a7 <> b9 Th
 			Pu Im bgb3 At a8, b9
 			Ge Im bgb3 Fm a6, a7
 			Pu Im b3 At a6, a7 Wi Trs
 			a8 = a6: b9 = a7
 		Ei
 		i = a0-1:
 		Rpt
 			d(i) = 1
 			Pu Im bgb0 Fr i At x(i),y(i)
 			DEC i
 		Un i < 0
 		i = 0:
 		Rpt
 			Ad x(i), dx(i)
 			Ad y(i), dy(i)
 			Ge Im bgb0 Fr i Fm x(i),y(i)
 			Pu Im b0 At x(i), y(i) Wi Trs
 			INC i
 		Un i = a0
 		Fil d Wi 0
 		ALLOW
 	Lp
 	
 Ee Prcd
 
 'Pr Prcd c1
 '
 '	Do
 '		Wh c2: DEC c2: We
 '		If Ju(0) An a7 > 0 An Pt(a6 + 4, a7 - 16) = Bl Th
 '			Ad a7, -16
 '			c2 = 10
 '		Ei
 '		If Jd(0) An a7 < a3 An Pt(a6 + 4, a7 + 16) = Bl Th
 '			Ad a7, 16
 '			c2 = 10
 '		Ei
 '		If Jl(0) An a6 > 16 An Pt(a6 - a1, a7) = Bl Th
 '			Ad a6, -a1
 '			c2 = 10
 '		Ei
 '		If Jr(0) An a6 < a3 An Pt(a6 + 8 + a1, a7) = Bl Th
 '			Ad a6, a1
 '			c2 = 10
 '		Ei
 '	Lp
 '		
 'Ee Prb
 
 b5[]
 b6s[]
 
 Fo k=0 To a0-1
 	Sw c8
 Nx k
 Sw c9
 'Sw c1
 
 
  ' balls -> a0
  ' step -> a1
  ' levels -> a2
  ' screenLimitH -> a3
  ' screenLimitW -> a4
  ' ballStep -> a5
  ' plx -> a6
  ' ply -> a7
  ' pvx -> a8
  ' pvy -> b9
  ' ball -> b0
  ' bar -> b1
  ' bgball -> b2
  ' paddle -> b3
  ' bgpaddle -> b4
  ' prepareGraphics -> b5
  ' drawBarrier -> b6
  ' drawBarriers -> b7
  ' moveBall -> c8
  ' drawBallsAndPaddle -> c9
  ' maxy -> c0
  ' movePlayer -> c1
  ' pdelay -> c2
 
 

SOURCE FILE

HOW TO COMPILE AND RUN

The instructions here refer to compiling the example from the command line. For Microsoft Windows users we suggest using UGBASIC-IDE, which allows you to compile the example with just one click.

ATARI 400/800 family

In order to compile and run the example, you need to have the Altirra emulator, and in particular that the altirra executable is accessible.

Then, type this command on the command line:

 # Linux 
 ugbc.atari x.bas -o example.xex
 altirra example.xex
 
 # Windows 
 ugbc.atari.exe x.bas -o example.xex
 altirra example.xex

ATARI 600XL/800XL/1200XL/XG(SE) family

In order to compile and run the example, you need to have the Altirra emulator, and in particular that the altirra executable is accessible.

Then, type this command on the command line:

 # Linux 
 ugbc.atarixl x.bas -o example.xex
 altirra example.xex
 
 # Windows 
 ugbc.atarixl.exe x.bas -o example.xex
 altirra example.xex

Commodore 64

In order to compile and run the example, you need to have the VICE emulator, and in particular that the x64sc executable is accessible.

Then, type this command on the command line:

 # Linux 
 ugbc.c64 x.bas -o example.prg
 x64sc example.prg
 
 # Windows 
 ugbc.c64.exe x.bas -o example.prg
 x64sc example.prg

Commodore PLUS/4

Using YAPE

In order to run the example, you need to have the YAPE emulator. In particular that the yape executable is accessible.

Then, type this command on the command line:

 # Linux 
 ugbc.plus4 x.bas -o example.prg
 yape example.prg
 
 # Windows 
 ugbc.plus4.exe x.bas -o example.prg
 yape example.prg
Using VICE

In order to run the example, you need to have the VICE emulator. In particular that the xplus4 executable is accessible.

Then, type this command on the command line:

 # Linux 
 ugbc.plus4 x.bas -o example.prg
 xplus4 example.prg
 
 # Windows 
 ugbc.plus4.exe x.bas -o example.prg
 xplus4 example.prg

Dragon 32

In order to compile and run the example, you need to have the XROAR emulator, and in particular that the xroar executable is accessible.

Then, type this command on the command line:

 # Linux 
 ugbc.d32 x.bas -o example.bin
 xroar -rompath (your rom path) example.bin
 
 # Windows 
 ugbc.d32.exe x.bas -o example.bin
 xroar.exe -rompath (your rom path) example.bin

Dragon 64

In order to compile and run the example, you need to have the XROAR emulator, and in particular that the xroar executable is accessible.

Then, type this command on the command line:

 # Linux 
 ugbc.d64 x.bas -o example.bin
 xroar -rompath (your rom path) example.bin
 
 # Windows 
 ugbc.d64.exe x.bas -o example.bin
 xroar.exe -rompath (your rom path) example.bin

PC128 Olivetti Prodest

In order to compile and run the example, you need to have the DCMOTO emulator, and in particular that the dcmoto executable is accessible.

Then, type this command on the command line and on the emulator:

 # Linux 
 ugbc.pc128op x.bas -o example.k7
 dcmoto
 (choose BASIC 128)
 CLEAR,&H2FFF: LOADM"CASS:",R: EXEC
 
 # Windows 
 ugbc.pc128op.exe x.bas -o example.k7
 dcmoto
 (choose example.k7)
 (choose BASIC 128)
 CLEAR,&H2FFF: LOADM"CASS:",R: EXEC

Thomson MO5

In order to compile and run the example, you need to have the DCMOTO emulator, and in particular that the dcmoto executable is accessible.

Then, type this command on the command line and on the emulator:

 # Linux 
 ugbc.pc128op x.bas -o example.k7
 dcmoto
 (choose BASIC 128)
 CLEAR,&H2FFF: LOADM"CASS:",R: EXEC
 
 # Windows 
 ugbc.pc128op.exe x.bas -o example.k7
 dcmoto
 (choose example.k7)
 (choose BASIC 128)
 CLEAR,&H2FFF: LOADM"CASS:",R: EXEC

Commodore VIC-20

In order to compile and run the example, you need to have the VICE emulator, and in particular that the xvic executable is accessible.

Then, type this command on the command line:

 # Linux 
 ugbc.vic20 x.bas -o example.prg
 xvic --memory 24k example.prg
 
 # Windows 
 ugbc.vic20.exe x.bas -o example.prg
 xvic --memory 24k example.prg

ZX Spectrum

In order to compile and run the example, you need to have the Speccy emulator, and in particular that the speccy executable is accessible.

Then, type this command on the command line:

 # Linux 
 ugbc.zx x.bas -o example.tap
 Speccy example.tap
 
 # Windows 
 ugbc.zx.exe x.bas -o example.tap
 Speccy example.tap

MSX

In order to compile and run the example, you need to have the openMsx or the BlueMSX emulator, and in particular that its executable is accessible.

Then, type this command on the command line:

openMSX
 # Linux 
 ugbc.msx1 x.bas -o example.rom
 openmsx -cart example.rom
 
 # Windows 
 ugbc.msx1.exe x.bas -o example.rom
 openmsx -cart example.rom
blueMSX
 # Linux 
 ugbc.msx1 x.bas -o example.rom
 bluemsx example.rom
 
 # Windows 
 ugbc.msx1.exe x.bas -o example.rom
 bluemsx example.rom

ColecoVision

In order to compile and run the example, you need to have the openMsx or the BlueMSX emulator, and in particular that its executable is accessible.

Then, type this command on the command line:

openMSX
 # Linux 
 ugbc.coleco x.bas -o example.rom
 openmsx -machine \"COL - ColecoVision\" -cart example.rom
 
 # Windows 
 ugbc.coleco.exe x.bas -o example.rom
 bluemsx -machine \"COL - ColecoVision\" example.rom
blueMSX
 # Linux 
 ugbc.coleco x.bas -o example.rom
 bluemsx /machine \"COL - ColecoVision\" /rom1 example.rom
 
 # Windows 
 ugbc.coleco.exe x.bas -o example.rom
 bluemsx  /machine \"COL - ColecoVision\" /rom1 example.rom

SEGA SC-3000

In order to compile and run the example, you need to have the BlueMSX emulator, and in particular that its executable is accessible.

Then, type this command on the command line:

 # Linux 
 ugbc.sc3000 x.bas -o example.rom
 bluemsx /machine \"SEGA - SC-3000\" /rom1 example.rom
 
 # Windows 
 ugbc.sc3000.exe x.bas -o example.rom
 bluemsx  /machine \"SEGA - SC-3000\" /rom1 example.rom

SEGA SG-1000

In order to compile and run the example, you need to have the BlueMSX emulator, and in particular that its executable is accessible.

Then, type this command on the command line:

 # Linux 
 ugbc.sg1000 x.bas -o example.rom
 bluemsx /machine \"SEGA - SG-1000\" /rom1 example.rom
 
 # Windows 
 ugbc.sg1000.exe x.bas -o example.rom
 bluemsx  /machine \"SEGA - SG-1000\" /rom1 example.rom

ANY PROBLEM?

If you have found a problem trying to run this example, if you think there is a bug or, more simply, you would like it to be improved, open an issue for this example on GitHub. Thank you!

POWERED BY