The other day I tried computation of on 8-bit Famicom Clone SB-2000, which can be detailed here, here, and here.
After I got BBG Famicom Clone [here] and here, I decided to let SB2000 go (already put on sale on Ebay). The PI computation program of F-BASIC does not work on BBG Famiclone unless a few modifications are made. The BASIC programming language is considered the most platform independent language for all famicoms with keyboard.
By the way, after I install the USB Floppy Emulator that replaces the floppy drive, it is not convenient to exchange data between PC and BBG Famicom. Therefore, I decide to use the following old rare 128M USB stick and format it as a single 1.44M Floppy disk that can be recognized by both PC and USB Floppy Emulator. Files can be just simply dragged and dropped. Please note that the single-1.44M-usb will work only if the indicator on USB floppy emulator is set to 000 (the first emulated floppy).
The differences between SB2000-F-BASIC and BASIC on BBG Famicom Clone (in this case, BBG-Floppy1 or BBG1):
1. On BBG1, the ‘THEN‘ cannot be omitted while on SB2000, it can be. For example, on BBG, you have to write
1 | if a=1 then 10 else 20 |
if a=1 then 10 else 20
2. On BBG1, the ‘DIM‘ array only takes constant values while in SB2000, it can be variables (works like REDIM).
3. On BBG1, the array index starts at ONE but on SB2000, it starts at ZERO.
4. On BBG1, there is no such thing as MOD, so you have to use the following equation to compute x % y:
1 | mod = x - int(x/y) * y |
mod = x - int(x/y) * y
5. On BBG1, you can use def fn to start a single-parameter function definition, works like a lambda function:
1 2 | def fn sqr(x)=x*x
print fn sqr(3) |
def fn sqr(x)=x*x print fn sqr(3)
6. On BBG1, you can use clear to clear all variables on workspace. There are more functions such as time and date so you can time your program. There is call function which can be used to run code given a memory location or run an external program.
7. On BBG1, you can draw using circle, dot, color and line.
8. On BBG1, you can peek and poke the memory (read from or write to a memory location). So for example, you can dump the bios easily.
After modification, the BASIC program runs on BBG.
The last few digits may not be converged specifically due to algorithm. And it is again, very slow on 8-bit Famicom (or Famiclones) using BASIC, the interpreting language. To improve the accuracy, you can change the line 10 to for example, N=30.
BASIC source code of PI Computation on FC
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | 1 REM ********************************* 2 REM *RUN ON BUBUGAO BBG * 3 REM *F-BASIC PROGRAM BY HELLOACM.COM* 4 REM *BY HTTPS://HELLOACM.COM * 5 REM ********************************* 6 CLEAR 7 PRINT "PI COMPUTATION":PRINT" --- MADE BY DR justyy" 9 PRINT "START TIME:":PRINT TIME$(":") 10 N=15 11 REM CHANGE ABOVE N FOR PRECISION 15 PRINT "VISIT HTTPS://HELLOACM.COM" 16 REM BBG BASIC ONLY SUPPORTS DIM WITH CONTANTS 17 REM MAXIMUM UPBOUND CHANGE IF NECESSARY 18 PRINT "COMPUTE ";N;" DECIMAL PLACES..." 19 PRINT "PLEASE WAIT... THANK YOU!" 20 REM ***** VARIABLE DECLARATION ***** 25 DIM X(100) 30 DIM Z(100) 31 REM FOR I=1 TO N 32 REM X(I)=0 33 REM Z(I)=0 34 REM NEXT I 40 X(2)=2 50 Z(2)=2 60 A=1 70 B=3 75 REM ***** START COMPUTATION ***** 80 D=0 90 J=N 95 IF J=0 THEN GOTO 140 100 C=Z(J)*A+D 110 Z(J)=C-INT(C/10)*10 120 D=INT(C/10) 130 J=J-1 135 GOTO 95 140 D=0 145 J=1 150 IF J>N THEN GOTO 200 160 C=Z(J)+D*10 170 Z(J)=INT(C/B) 180 D=C-Z(J)*B 190 J=J+1 195 GOTO 150 200 R=0 210 J=N 215 IF J=1 THEN GOTO 280 220 C=X(J)+Z(J) 230 X(J)=C-INT(C/10)*10 240 X(J-1)=X(J-1)+INT(C/10) 250 R=R+Z(J) 260 J=J-1 270 GOTO 215 275 REM ***** CHECK SHOULD WE END ***** 280 IF R=0 THEN GOTO 300 290 A=A+1 292 B=B+2 295 GOTO 80 296 REM *****PRINT THE RESULT***** 300 FOR T=1 TO N 301 PRINT STR$(X(T)); 302 NEXT T 303 PRINT "" 330 PRINT "END TIME:":PRINT TIME$(":") 335 END |
1 REM ********************************* 2 REM *RUN ON BUBUGAO BBG * 3 REM *F-BASIC PROGRAM BY HELLOACM.COM* 4 REM *BY HTTPS://HELLOACM.COM * 5 REM ********************************* 6 CLEAR 7 PRINT "PI COMPUTATION":PRINT" --- MADE BY DR justyy" 9 PRINT "START TIME:":PRINT TIME$(":") 10 N=15 11 REM CHANGE ABOVE N FOR PRECISION 15 PRINT "VISIT HTTPS://HELLOACM.COM" 16 REM BBG BASIC ONLY SUPPORTS DIM WITH CONTANTS 17 REM MAXIMUM UPBOUND CHANGE IF NECESSARY 18 PRINT "COMPUTE ";N;" DECIMAL PLACES..." 19 PRINT "PLEASE WAIT... THANK YOU!" 20 REM ***** VARIABLE DECLARATION ***** 25 DIM X(100) 30 DIM Z(100) 31 REM FOR I=1 TO N 32 REM X(I)=0 33 REM Z(I)=0 34 REM NEXT I 40 X(2)=2 50 Z(2)=2 60 A=1 70 B=3 75 REM ***** START COMPUTATION ***** 80 D=0 90 J=N 95 IF J=0 THEN GOTO 140 100 C=Z(J)*A+D 110 Z(J)=C-INT(C/10)*10 120 D=INT(C/10) 130 J=J-1 135 GOTO 95 140 D=0 145 J=1 150 IF J>N THEN GOTO 200 160 C=Z(J)+D*10 170 Z(J)=INT(C/B) 180 D=C-Z(J)*B 190 J=J+1 195 GOTO 150 200 R=0 210 J=N 215 IF J=1 THEN GOTO 280 220 C=X(J)+Z(J) 230 X(J)=C-INT(C/10)*10 240 X(J-1)=X(J-1)+INT(C/10) 250 R=R+Z(J) 260 J=J-1 270 GOTO 215 275 REM ***** CHECK SHOULD WE END ***** 280 IF R=0 THEN GOTO 300 290 A=A+1 292 B=B+2 295 GOTO 80 296 REM *****PRINT THE RESULT***** 300 FOR T=1 TO N 301 PRINT STR$(X(T)); 302 NEXT T 303 PRINT "" 330 PRINT "END TIME:":PRINT TIME$(":") 335 END
Load the source code using the Load command in the FC BASIC prompt and hit Run.
–EOF (The Ultimate Computing & Technology Blog) —
loading...
Last Post: 8-bit 6502 Assembly for Famicom Clone BBG - Tutorial 1
Next Post: Using Peek function to read from Memory on BBG Famicom Clone on Basic Programming Language