List almost all SHIFT-JIS code which was supported in X68000.
It produced SHIFT-JIS code in arithmetic, and it convert to UTF8 when displaying.
Please run under SHIFT-JIS forced mode is OFF.
/* List all SHIFT-JIS code by UTF8
// X-BASIC for iOS can not text screen scroll, so it is displayed page by page.
font("Migu 1M")
int fzenhan:// YES=
width(64,,fzenhan)
print "fzenhan=";fzenhan
cls()
if isLocalizeJapan() then {
setFunctionKey(0,"次へ",&h0d)
setFunctionKey(1,"中断",&h1b)
print "半角文字"
} else {
setFunctionKey(0,"Next",&h0d)
setFunctionKey(1,"Break",&h1b)
print "Half-Width Character"
}
print_code0(fzenhan)
//
displayFunctionKey(YES,0,1)
//
while YES
if print_code(&h8100,&h9fff) then break
if print_code(&he000,&hefff) then break
print_head()
break
endwhile
// The previous function key display will not erase automatically when changing the number.
// The user must erase(View overlaps with otherwise).
displayFunctionKey(NO,0,1)
if isLocalizeJapan() then {
setFunctionKey(0,"終了",&h0d)
} else {
setFunctionKey(0,"End",&h0d)
}
displayFunctionKey(YES,0,0)
int ky
repeat
ky=inkey()
until ky<>0
end
//--------------------------------
func print_head()
if fzenhan then {
print "-code-:-+0-+1-+2-+3-+4-+5-+6-+7-+8-+9-+A-+B-+C-+D-+E-+F-"
} else {
print "-code-:-0-1-2-3-4-5-6-7-8-9-A-B-C-D-E-F-"
}
endfunc
func print_skip()
print " : "
endfunc
func str hex4$(h;int)
return (right$("0000"+hex$(h),4))
endfunc
func str hex2$(h;int)
return (right$("00"+hex$(h),2))
endfunc
func printChr(h;int,l;int)
print chr$((h shl 16)or l);
endfunc
func int print_code(st;int,ed;int)
/* Double-Width character display
int i,li,hi
int j
for i=st to ed
hi=i / 256
li=i mod 256
if li=0 then {
print_head()
int ky
int ts=time()
int dt=0,t
repeat
ky=inkey()
t=time()
if t-ts>dt then { :/* change second
dt=dt+1
locate(40,0):print dt
beep2(0)
}
until ky<>0
if ky=&h1b then return (YES)
cls()
if isLocalizeJapan() then {
print "全角文字"
} else {
print "Double-Width character"
}
print_head()
}
if li<&h40 then continue:/* The chatacter which low 8bit code<$40 is none
/* print adrs
print " ";hex4$(i);" :";
for j=0 to 16-1
print " ";
int c=(i+j) and &hff
if c<&h40 or c=&h7f or c>=&hfd then { /* undefined character
if fzenhan then {
print "**";
} else {
print "*";
}
} else {
c=sjisToUtf8(i+j)
print chr$(c); :/* This was treated on the assumption that it does not cause a carry on the way
}
next
print
i=i+16-1:/* +1 in below 'next'
next
return (NO)
endfunc
func print_code0(fzenhan;int)
/* half width character display
int li
int j,c
print_head()
for li=&h20 to &he0-1
/* skip area
if li=&h80 then print_skip()
if li>=&h80 and li<=&h9f then continue
/* print adrs
print " ";hex2$(li);" :";
/* print character
for j=0 to 16-1
print " ";
c=li+j
if c=&h7f or c=&ha0 then c='*' else c=sjisToUtf8(c)
print chr$(c);
if fzenhan then print " ";:/* if Double-width equal half-width*2 then print space
next
print
li=li+16-1:/* +1 in below 'next'
next
endfunc
Bingo game. You play against the computer.
This has set up a lot of the touch area.
This is only for iPad within portlait because of screen size.
//--------------------------------------------------------------------------------
/* BINGO
// for X-BASIC for iOS v2.0
//--------------------------------------------------------------------------------
if deviceType()<>DEVICE_IPAD and deviceType()<>DEVICE_IPAD_SIMULATOR then {
print localizedString("このプログラムはiPad専用です","This program only for iPad.")
end
}
dim int A(5,11),B(12,2)
dim int keyAreaNo(5,5)
int d,L,T,E,F
int WX,WY
int sx,sy,ex,ey
int OPEND=100:// constant
/*
srand2()
width(64)
getWidth(WX,WY)
setUpScroll(NO):// disable to up scroll (V2.0)
apage(GPAGE0)
vpage(B_TPAGE or B_GPAGE0 or B_GPAGE1,YES)
//display_title()
d=0
dim str menues(1)
str title
int e
repeat
cls()
apage(GPAGE1):wipe()
apage(GPAGE0):wipe()
gcolor(-TWHITE,0,0,255)
symbol(128,2,"BINGO GAME","IPAGothic",48)
gcolor(-THWHITE,0,0,255)
symbol(129,3,"BINGO GAME","IPAGothic",48)
gcolor(-THRED,0,0,255)
box(13,64,748,614)
tcolor(-THWHITE,0,0,255)
shuffle():// set numbers
field_print():// display numbers and set touch area
print_number(NO)
/*
if isLocalizeJapan() then {
menues={"先手","後手"}
title="順番選択"
} else {
menues={"First move","Passive move"}
title="Moving order"
}
repeat
L=selectMenu2(title,menues):// -1,0,1
until L>=0:// -1=BREAK/outside menu touch
L=L+1:// 0,1->1,2
sub_cls()
/*
for e=0 to 12
B(e,0)=0
B(e,1)=0
B(e,2)=0
next
E=0:F=0:T=0
repeat
T=T+1
tcolor(-THWHITE,0,0,255)
locate(6,17)
if isLocalizeJapan() then {
print"第";T;"手"
} else {
print"The";T;" hand"
}
repeat
switch L
case 1:
locate(11,19)
print localizedString("あなた:","You : ");
d=input_num()
L=2
break
case 2:
locate(38,19)
print localizedString("コンピューター:","Computer : ");
d=com_num()
//beep()
L=1
break
endswitch
int cx=pos()
int cy=csrlin()
int ffind=check_num(d)
if not ffind then {
// not found
// Human side only
L=1
beep()
// input retry
}
until ffind
locate(cx,cy):print d
until (F>=5) or (E>=5)
resetALlKeys():// remove touch area
sub_cls()
print_number(YES)
hantei(E,F)
locate(11,24)
if isLocalizeJapan() then {
print "御苦労さまでした"
menues={"はい","いいえ"}
title="もう一度しますか?"
} else {
print "Cheers for hard work was."
menues={"YES","NO"}
title="Try again ?"
}
L=selectMenu2(title,menues):// -1=stop,0=YES,1=NO
until L=1 or L=-1
end
//--------------------------------------------------------------------------------
// functions
//--------------------------------------------------------------------------------
func hantei(E;int,F;int)
/* game decision
tcolor(-THYELLOW,0,0,255)
locate(10,23)
if isLocalizeJapan() then {
print E;" 対";F;"で ";
}
if F<E then {
print localizedString("あなたの勝ち","You win");
} else {
if E<F then {
print localizedString("コンピューターの勝ち","Computer win");
} else {
print localizedString("引き分け","Draw");
}
}
if not isLocalizeJapan() then {
print " in the";E;"-for-";F
}
endfunc
/*
func int input_num()
/* human's number select
int num
// kbclr()
// wait key input
while not kbhit()
endwhile
// if you touch the grid then return keycode as number
num=inkey()
return(num)
endfunc
/*
func int check_num(d;int)
/* check number and grid open
int h,x,y,ac,bb,i,j
for h=1 to 2:// check both
// get grid coordinate from number
int ffind=NO
for i=1 to 5
for j=1 to 5
ac=A(i,j+(h-1)*6)
if ac=d then {
x=i:y=j
ffind=YES
break
}
next
if ffind then break
next
if not ffind then {
// not found
locate(0,5):print "見つからない"
return (NO)
}
//
apage(GPAGE1)
switch h
case 1:gcolor(-THMAGENTA,0,0,200):break
case 2:gcolor(-THGREEN ,0,0,200):break
endswitch
calc_grid_gxy(x,y,h-1):// ->sx,sy,ex,ey
fill(sx,sy,ex,ey)
apage(GPAGE0)
//
A(x,y+(h-1)*6)=ac+OPEND:/* opened symbol
bb=0
if x=y then bb=B(12,h):B(12,h)=bb+1
if x=6-y then bb=B(11,h):B(11,h)=bb+1
bb=B(x,h) :B(x ,h)=bb+1
bb=B(y+5,h):B(y+5,h)=bb+1
x=0
for i=1 to 12
x=x+B(i,h)\5
next
if (h=1) and (E<x) then {
locate(11,15)
if isLocalizeJapan() then {
print "あなた:";x;"列"
} else {
print "You :";x;" lines"
}
E=x
beep2(7)
} else {
if (h=2)*(F<x) then {
locate(38,15)
if isLocalizeJapan() then {
print "コンピューター:";x;"列"
} else {
print "Computer :";x;" lines"
}
F=x
beep2(8)
}
}
next
// found and processed
return (YES)
endfunc
/*
func int com_num()
/* computer thinking
int i,j,m,bb,c
m=0
for i=1 to 5
for j=1 to 5
bb=0
if A(i,j+6)<OPEND then {
if i=j then bb= 1+B(12,2)
if i=6-j then bb=bb+1+B(11,2)
bb=bb+2+B(i,2)+B(j+5,2)
if bb>m then c=A(i,j+6):m=bb
}
next
next
// locate(0,26):print "com=";c
return(c)
endfunc
/*
func sub_cls()
/* clear part of screen
int y
for y=16 to WY
locate(0,y):print space$(WX);
next
endfunc
/*
func shuffle()
/* shuffle the number in grid
int i,j,l,h
int c,x,y
for l=0 to 1:/* l=0:you , 1=computer
/* enter number to grid in order
/* A(i,j) : j=1〜5:yours , 6〜11:computer
h=0
for i=1 to 5
for j=1 to 5
h=h+1
A(i,j+l*6)=h
next
next
/* exchange number
for i=1 to 5
for j=1 to 5
x=rand() mod 5+1
y=rand() mod 5+1+l*6
c=A(i,j+l*6)
A(i,j+l*6)=A(x,y)
A(x,y)=c
next
next
next
endfunc
/*
func print_number(mode;int)
/* display the number in grid
// mode : NO=Human , YES=Computer
int i,j,c
int x,y
tcolor(-THWHITE,0,0,255)
for i=1 to 5
x=(i-1)*5
for j=1 to 5
y=j*2+2
if not mode then {
// Human
c=A(i,j)
if c>OPEND then c=c-OPEND:/* opened grid
locate(x+ 7,y):print using "##";c
locate(x+36,y):print "??"
} else {
// Computer
c=A(i,j+6)
if c>OPEND then c=c-OPEND:/* opened grid
locate(x+36,y):print using "##";c
}
next
next
endfunc
/*
func field_print()
/* draw field
// In advance that you'll accept the number with shuffle()
int l,i,j
for l=0 to 1:/* l=0:You , 1=Computer
if l=0 then {
tcolor(-THCYAN,0,0,255)
locate(11,14)
print localizedString("あなたのマス目","Your grid")
} else {
tcolor(-THYELLOW,0,0,255)
locate(36,14)
print localizedString("コンピューターのマス目"," Computer grid ")
}
// draw grid
gcolor(-THMAGENTA,0,0,255)
for i=1 to 5
for j=1 to 5
calc_grid_gxy(i,j,l):// ->sx,sy,ex,ey
box(sx,sy,ex,ey)
if l=0 then {
// set toucha area
// only human area
// keyCode is the number
keyAreaNo(i,j)=setTouchArea(sx,sy,(ex-sx),(ey-sy),A(i,j),YES)
// save touch area No into keyAreaNo()
}
next
next
next
tcolor(-THWHITE,0,0,255)
endfunc
/*
func resetALlKeys()
// reset all key touch area (important)
int i,j
for i=1 to 5
for j=1 to 5
removeTouchArea(keyAreaNo(i,j))
next
next
endfunc
/*
func calc_grid_gxy(i;int,j;int,l;int)
// calc graphic coordinate from grid coordinate
int x,y
x=textX2Gx((i-1)*5+7)+l*340
y=textY2Gy(j*2+2)
// below return value (grobal variable)
ex=textX2Gx((i-1+1)*5+7)+l*340-12
ey=textY2Gy((j+1)*2+2)-12
sx=x-12
sy=y-12
endfunc
/*
func display_title()
/* title screen
int i,x
str s,s1
wipe()
lineWidth(2)
gcolor(-THRED,0,0,255)
box(61,4,448,128)
gcolor(-THMAGENTA,0,0,200)
fill(63,6,446,126)
s="BINGO"
for i=0 to 4
x=i*70+90
s1=utf8Mid$(s,i+1,1)
gcolor(-TWHITE,0,0,255)
symbol(x-11,16,s1,"Times New Roman",64)
gcolor(-THWHITE,0,0,255)
symbol(x-9 ,18,s1,"Times New Roman",64)
next
/*
gcolor(-TGREEN,0,0,255) :fill(112,180,400,320)
//
str copyright="Presented by AIG-SOFT"
str forMachine="for X-BASIC or iOS"
gcolor(-TWHITE,0,0,255)
symbol(170,201,copyright,"IPAGothic",16)
symbol(180,231,forMachine,"IPAGothic",16)
gcolor(-THWHITE,0,0,255)
symbol(169,200,copyright,"IPAGothic",16)
symbol(179,230,forMachine,"IPAGothic",16)
//
gcolor(-THRED,0,0,255)
box(109,178,403,324)
hitKey()
endfunc
/*
func srand2()
/* random number initialize
int t
t=val(right$(time$,2))+val(mid$(time$,4,2))
srand(t*16)
endfunc
/*
func hitKey()
setFunctionKey(0,localizedString("ここを押してください","Hit This Button"),'!')
displayFunctionKey(YES,0,0)
while inkey()=0
endwhile
cls()
displayFunctionKey(NO,0,0)
endfunc
func str localizedString(js;str,es;str)
if isLocalizeJapan() then return(js)
return (es)
endfunc
//--------------------------------------------------------------------------------
This is a sample program of e-mail function.
Please be prepared to png file separately to make the attachment.
//------------------------------------------------
/* eMailSend() test
//------------------------------------------------
dim str fileList(256):// Inside () is the maximum number of files that can be handled
int cnt
// Test with changing here png->jpeg
cnt=files(fileList,"","bas",YES,FILES_FILE)
if isLocalizeJapan() then {
print "該当ファイル数=";cnt
} else {
print "Corresponding file number=";cnt
}
int i
for i=0 to cnt-1
print i;":";fileList(i)
next
// (1)no attachment
if isLocalizeJapan() then {
print "(1)添付なし"
emailSend("件名1","本文1")
} else {
print "(1)no attachment"
emailSend("subject1","body1")
}
//hitKey()
// (2)attach each file
if isLocalizeJapan() then {
print "(2)そのまま添付"
emailSend("件名2","本文2(添付付き)",fileList,3)
} else {
print "(2)attach each file"
emailSend("subject2","body2(with attachment)",fileList,3)
}
//hitKey()
// (3)attach with zip archive
if isLocalizeJapan() then {
print "(3)zip圧縮添付"
emailSend("件名3","本文3(zip添付付き)",fileList,10,"testzip.zip")
} else {
print "(3)attach with zip archive"
emailSend("subject3","body3(zip archive)",fileList,10,"testzip.zip")
}
if isLocalizeJapan() then {
print "全送信終了"
} else {
print "All send finish."
}
//------------------------------------------------
end
//------------------------------------------------
func hitKey()
str exit$
if isLocalizeJapan() then {
exit$="次へ"
} else {
exit$="To Next"
}
setFunctionKey(0,exit$,'!')
displayFunctionKey(YES,0,0)
while inkey()=0
endwhile
cls()
displayFunctionKey(NO,0,0)
endfunc
This is a test program of electronic compass function.
This can not use in iPod touch because iPod touch does not have electric compass.
This is the difference between iPhone and iPod touch except phone function.
//----------------------------------------------------------------------------------------------
// compass test
//----------------------------------------------------------------------------------------------
print "version Motion=";versionXBiOSMotion$()
font("Cochin",6):// Function Key's Font
setFunctionKey(0,"end" ,'!')
setFunctionKey(1,"pause" ,'p')
setFunctionKey(2,"start" ,'s')
setFunctionKey(3,"clear" ,'c')
displayFunctionKey(YES,0,3)
kBackgroundAlpha(0.9)
font("IPAGothic")
if compassStart(10) then {
print localizedString("方位取得は使えません","Can't use compass.")
end
}
float degree,magnetic
int ky,cnt,i
while YES
if not kbhit() then {
i=0
cnt=compassCount()
if cnt>0 then locate(0,1):print "cnt=";cnt
while cnt>0
degree=compassGetData(magnetic)
locate(0,2+i)
if isLocalizeJapan() then {
print using "極北からの角度=###.####,磁北からの角度=###.####";degree,magnetic
} else {
print using "true=###.####,magnetic=###.####";degree,magnetic
}
cnt=cnt-1
i=i+1
if kbhit() then break
endwhile
} else {
ky=inkey()
switch ky
case 'p'
compassPause(YES)
print "Pause"
break
case 's'
compassPause(NO)
print "Start"
break
case 'c'
cls()
compassClear()
break
default:
// just in case
beep()
break
endswitch
if ky='!' then break
}
endwhile
compassEnd()
end
//----------------------------------------------------------------------------------------------
func str localizedString(js;str,es;str)
if isLocalizeJapan() then return(js)
return (es)
endfunc
//----------------------------------------------------------------------------------------------
It is a test program of audio function.
Please set your own sound file in a_setPlayData().
This sample song is from "Muff&Huff" by MankaiSeisakusho(freely available).
// audio test
// Write your own sound file name
// This sample music from "Muff&Huff" by MankaiSeisakusho.
int sno=a_setPlayData("EARTH SONG #1.mp3")
if (sno=-2) then {
print "sound file not found."
end
}
int wx
//
dim int touchNo(10) :// touch area number
int touchCnt :// the number of touch area
font("IPAGothic")
int fzenhan
int WX=64:if deviceType()<>1 then WX=48
int WY=width(WX,,fzenhan)
int xw=1
if fzenhan then xw=2
str exit$
if isLocalizeJapan() then {
exit$="中断"
} else {
exit$="exit"
}
int x=WX/2-18
int y=WY/2
// 012345678901234567890123456789
locate(x,y+0):print " ┏━┓"
locate(x,y+1):print " ┃8┃"
locate(x,y+2):print " ┗━┛"
locate(x,y+3):print "┏━┓┏━┓┏━┓ ┏━━┓"
locate(x,y+4):print "┃4┃┃?┃┃6┃ ┃";exit$;"┃"
locate(x,y+5):print "┗━┛┗━┛┗━┛ ┗━━┛"
locate(x,y+6):print " ┏━┓"
locate(x,y+7):print " ┃2┃"
locate(x,y+8):print " ┗━┛"
int i=0
touchNo(inc(i))=setTouchArea(textX2Gx(x+ 6),textY2Gy(y ),textX2Gx(xw*3),textY2Gy(3),'8',YES, 0,50,55,220)
touchNo(inc(i))=setTouchArea(textX2Gx(x+ 6),textY2Gy(y+6),textX2Gx(xw*3),textY2Gy(3),'2',YES, 0,50,55,220)
touchNo(inc(i))=setTouchArea(textX2Gx(x ),textY2Gy(y+3),textX2Gx(xw*3),textY2Gy(3),'4',YES, 0,50,55,220)
touchNo(inc(i))=setTouchArea(textX2Gx(x+12),textY2Gy(y+3),textX2Gx(xw*3),textY2Gy(3),'6',YES, 0,50,55,220)
//
touchNo(inc(i))=setTouchArea(textX2Gx(x+ 6),textY2Gy(y+3),textX2Gx(xw*3),textY2Gy(3),'?',YES,150,50, 5,120)
touchNo(inc(i))=setTouchArea(textX2Gx(x+22),textY2Gy(y+3),textX2Gx(xw*4),textY2Gy(3),'!',YES,150, 5 ,5,120)
touchCnt=i
//
keyRepeatTime(0,0):// repeat none
//
setFunctionKey(0,exit$,'!')
setFunctionKey(1,"V-UP",'u')
setFunctionKey(2,"V-DN",'d')
setFunctionKey(3,"SPD",'S')
setFunctionKey(4,"LP=1",'1')
setFunctionKey(5,"LP∞" ,'0')
setFunctionKey(6,"LP=2",'2')
setFunctionKey(7,"PAN",'c')
setFunctionKey(8,"stop",'s')
setFunctionKey(9,"cont",'C')
setFunctionKeyBackgroundImage("funcBack.png")
displayFunctionKeyAll(YES)
int speed=0
int pan=0
str cs
int dt=0,t
int ts=time():/* start time
locate(20,1)
a_play(sno)
while YES
// while a_stat(sno)
// timer count until key input
while (not kbhit())
/* キー入力の無い間
t=time()
if t-ts>dt then { :/* change second
dt=dt+1
locate(20,0):print dt;
beep2(0)
locate(20,1)
}
endwhile
// key operation
cs=inkey$()
switch cs
case "u":a_volume(sno,1.0):break
case "d":a_volume(sno,0.05):break
case "S":
switch speed
case 0:a_speed(sno,2.0):break
case 1:a_speed(sno,0.5):break
case 2:a_speed(sno,1.0):break
endswitch
speed=speed+1
break
case "1":
a_loop(sno,1):print "loop=1"
break
case "2":
a_loop(sno,2):print "loop=2"
break
case "0":
a_loop(sno,0):print "loop=∞"
break
case "c":
switch pan
case 0:a_pan(sno,-1.0):inc(pan):break
case 1:a_pan(sno, 0.0):inc(pan):break
case 2:a_pan(sno, 1.0):pan=0:break
endswitch
break
case "r"
break
case "s":a_stop(sno):break
case "C":a_cont(sno):break
endswitch
print cs;
if cs="!" then break
endwhile
a_end(sno)
print "end"
end
func resetTouchArea()
// remove touch area
int i
for i=0 to touchCnt
removeTouchArea(touchNo(i))
next
touchCnt=0
endfunc
Zip file including sample sound file is here :
XBaudioTest.zip
Play all supported sound files sequentially.
At that time, it playes each type.
// Sound player
// for X-BASIC for iOS v1.7 later
width(64)
//
vpriority(TPAGE,GPAGE0,GPAGE1,GPAGE2,GPAGE3)
vpage(B_TPAGE or B_GPAGE0 or B_GPAGE1 or B_GPAGE2 or B_GPAGE3,YES)
apage(GPAGE0)
//
// Get all file list
dim str fileList(256):// max file
int allcnt
int i,ret
str ext
//
// Extension (case sensitive)
// Regular expression
ext="PCM|pcm|wav|WAV|aiff|AIFF|M44|P16|M30":
allcnt=files(fileList,"",ext,YES,FILES_FILE,YES)
if allcnt<=0 then {
locate(0,0)
print localizedString("音声ファイルがありません":"Sound file not found.")
} else {
int no
for i=0 to allcnt-1
locate(0,0):print fileList(i)
str pext=pathExtension(fileList(i))
strupr(pext)
if pext="PCM" then {
print "(ADPCM)"
no=a_setPlayData(fileList(i),0)
} else {
no=a_setPlayData(fileList(i))
}
a_play(no)
hitKey()
a_end(no)
next
}
end
//---------
func hitKey()
setFunctionKey(0,localizedString("ここを押してください","Hit This Button"),'!')
displayFunctionKey(YES,0,0)
while inkey()=0
endwhile
cls()
displayFunctionKey(NO,0,0)
endfunc
//---------
func str localizedString(js;str,es;str)
if isLocalizeJapan() then return(js)
return (es)
endfunc
//---------
This is a demo.
Drops is falling from above until it is full.
It repeat from the beginning.
If you want to stop, tap "[X]".
/******************************************************************/
/* Cascade Demo
/******************************************************************/
/* These are variables. These are not constant. So they can not use for dim size or case value.
int WX ://=(80/2)
int WY ://=24
int MAX =75 :/* number of shelves
int LNG =5 :/* max length of cascade
/* internal character
int WALL='#' :/* wall
int BALL='o' :/* drop
int TANA='=' :/* shelf
int SPC =' ' :/* space
int dx,dy :/* move direction
int clng :/* move pointer
int retY :/* second return value is returned via the global variable
dim int drpx(5) :/* move x position buffer (LNG)
dim int drpy(5) :/* move y position buffer (LNG)
dim char tvram(96,96) :/* virtual video RAM
:/* Size is variable depending on the model, It set aside the maximum value.
int wtt :/* wait
/******************************************************************/
/* main routine
/******************************************************************/
getWidth(WX,WY):// get text screen size(system set)
setUpScroll(NO):// disable to up scroll (V2.0)
WX=WX/2
MAX=(WX*WY/13)
int ts,t
/*int c
srand2() /* random initialize
wtt=CalcWait()/100*8:/* calc wait time (8ms)
repeat
InitScreen() :/* screen initialize
if Cascades() then break:/* move cascade
beep()
locate(8,7)
if isLocalizeJapan() then {
print "もう一度見ますか? ";
} else {
print "Watch again ?";
}
/* c='Y';
ts =time()
repeat:/* automatic repeat after 15 seconds
t=time()
until t-ts>=15
until NO :/*(c<>'Y' && c<>CR)
end
/******************************************************************/
/* below are internal functions
/******************************************************************/
func InitScreen()
/* make initial screen
int i,j,x,y
cls()
print " CASCADES"
init_tvram()
/* make outside wall
for y=1 to WY-2:/* vertical
storexy( 0,y,WALL)
storexy(WX-1,y,WALL)
next
for x=0 to WX-1:/* horizontal
storexy(x,WY-1,WALL)
next
/* make shelf
for i=0 to MAX-1
x=1+rand2(WX-2) :/* Except both ends
y=2+rand2(WY-3) :/* Except for the bottom line and the top and the next
for j=0 to 3
if (x+j>=WX-1) then break /* x-over
if (scrn(x+j,y)=SPC) then storexy(x+j,y,TANA)
next
next
// full screen display
printScreenAll(1,WY-1)
endfunc
/******************************************************************/
func int Cascades()
/* cascade move
int x,y
//int ts=time():/* start time
//int t,dt=0
while CheckDropPoint()=0
/* if there is open
/* set initial position
x=SetFirstPoint()
y=1
repeat
//t=time()
//if t-ts>dt then { :/* change second
// dt=dt+1
// locate(30,0):print dt;
//}
//if inkey()=ESC then return(1)
/* move and display
Drop(x,y)
if clng=0 then break
clng=clng-1
x=drpx(clng)
y=drpy(clng)
until x=0 and y=0
endwhile
/* if top line is full then terminate
return(0)
endfunc
/******************************************************************/
func int CheckDropPoint()
/* check top line open
int x
for x=1 to WX-2
if scrn(x,1)=SPC then return(0) :/* open
next
return(1) :/* close
endfunc
/******************************************************************/
func int SetFirstPoint()
/* start point setting (top line)
int i,x
x=1+rand2(WX-2):/* set start point
while scrn(x,1)<>SPC
x=x+1
if (x=WX-1) then x=1
endwhile
clng=LNG-1
for i=0 to clng-1
drpx(i)=0
drpy(i)=0:/* 0=non record symbol
next
drpx(clng)=x
drpy(clng)=1
dx=0
dy=1: /* to down
return(x)
endfunc
/******************************************************************/
func Drop(x;int,y;int)
/* move and display
int r,l
while (YES)
/* display
printxy(x,y,BALL)
TWait(wtt):/* wait
/* Is bottom open?
if scrn(x,y+1)=SPC then {
/* down fall
dx=0
dy=1
x=Move(x,y)
y=retY
continue
}
/* check destination
if scrn(x+dx,y+dy)=SPC then {
/* enable to move
x=Move(x,y)
y=retY
continue
}
/* can't move the destination
if (dy=1) then { :/* fall down
/* check left and right
r=(scrn(x+1,y)=SPC):/* right
l=(scrn(x-1,y)=SPC):/* left
/* change left or right move if it can move
dx=0
if (r) then { :/* right side is open
dx=1
}
if (l) then { :/* left side is open
dx=-1
if (r) then { :/* right side is open too
/* select left or right
if rand2(2)=1 then dx=1
}
}
if dx<>0 then {:/* enable to move
dy=0
x=Move(x,y)
y=retY
continue
}
}
/* if can't move anywhere then loop out
break
endwhile
endfunc
/******************************************************************/
func int Move(x;int,y;int)
/* move and erase
int i
if (drpy(0)<>0) then printxy(drpx(0),drpy(0),SPC):/* erase previous position
x=x+dx
y=y+dy
if (clng>=1) then {
for i=1 to clng
drpx(i-1)=drpx(i)
drpy(i-1)=drpy(i)
next
}
drpx(clng)=x
drpy(clng)=y
retY=y:/* second return value is returned via the global variable
return(x)
endfunc
/******************************************************************/
/* virtual text VRAM system
/******************************************************************/
func str printChar$(c;char)
/* get display characters
str c$
switch (c)
case ' ': c$= " ":break :/* erase
case 'o': c$= "●":break :/* drops
case '#': c$= "■":break :/* wall
case '=': c$= "□":break :/* shelf
endswitch
return (c$)
endfunc
func printxy(x;int,y;int,c;char)
/* display characters
/* output for virtual text VRAM
tvram(x,y)=c
/* position transrate
locate(x*2,y)
/* display with character transrate
print printChar$(c);
endfunc
func storexy(x;int,y;int,c;char)
/* output for virtual text VRAM
tvram(x,y)=c
endfunc
func char scrn(x;int,y;int)
/* read virtual text VRAM
return(tvram(x,y))
endfunc
func printScreenAll(stY;int,edY;int)
/* full screen display
/* X-BASIC for iOS's text display is so slow. Therefore this function is measured.
/* Remnant of V1.0
int x,y
str linestr
for y=stY to edY
linestr=""
for x=0 to WX-1
linestr=linestr+printChar$(tvram(x,y))
next
locate(0,y):print linestr;
next
endfunc
func init_tvram()
/* virtual text VRAM initialize
int x,y
for y=0 to WY-1
for x=0 to WX-1
tvram(x,y)=SPC
next
next
endfunc
/******************************************************************/
/* misc function
/******************************************************************/
func srand2()
/* rand() initialize
int tm
t=time()
tm=tm and &h0fff
tm=tm*16
srand(tm)
endfunc
func int rand2(seed;int)
/* generate random number
return (rand() mod seed)
endfunc
/******************************************************************/
func int CalcWait()
/* calc wait
int tim,tm
int count
/* Zero clock check
tm=time()
repeat
tim=time()
until tim-tm<>0
count=0
repeat
tm=time()
count=count+1
until tm-tim<>0
return(count):/* count number per 1 second
endfunc
/******************************************************************/
func TWait(wt;int)
int i,tm
for i=0 to wt-1
tm=time()
next
endfunc
/******************************************************************/
Display all supported image files sequentially.
At that time, it displays each type.
// Graphic file display
// for X-BASIC for iOS v1.7 later
width(64)
//
vpriority(TPAGE,GPAGE0,GPAGE1,GPAGE2,GPAGE3)
vpage(B_TPAGE or B_GPAGE0 or B_GPAGE1 or B_GPAGE2 or B_GPAGE3,YES)
apage(GPAGE0)
//
// get all file list
dim str fileList(256):// max file
int allcnt
int i,ret
str ext
//
// extension (case sensitive)
// Regular expression
ext="PIC|pic|PNG|png|JPG|jpg|CUT|cut":
allcnt=files(fileList,"",ext,YES,FILES_FILE,YES)
if allcnt<=0 then {
locate(0,0)
print localizedString("画像ファイルがありません":"Graphic file not found.")
} else {
for i=0 to allcnt-1
locate(0,0):print fileList(i)
wipe()
str pext=pathExtension(fileList(i))
strupr(pext)
switch pext
case "PIC"
ret=picLoader(128,128,fileList(i))
if ret<>0 then {
locate(0,1):print "Error=";ret
}
break
case "CUT"
ret=cutLoader(128,128,fileList(i))
if ret<>0 then {
locate(0,1):print "Error=";ret
}
break
default:
ret=imgLoad(128,128,0,0,fileList(i))
break
endswitch
hitKey()
next
}
end
//---------
func hitKey()
setFunctionKey(0,localizedString("ここを押してください","Hit This Button"),'!')
displayFunctionKey(YES,0,0)
while inkey()=0
endwhile
cls()
displayFunctionKey(NO,0,0)
endfunc
//---------
func str localizedString(js;str,es;str)
if isLocalizeJapan() then return(js)
return (es)
endfunc
//---------
Zip file including sample image files is here : XBpicloader.zip
This is a simple filer. You can view file and directorylist and delete it.
Files created by the user in the program are continue to remain inside until you delete in the program.So I made this for removing unnecessary your files.
However, it can delete the files only created by the user except program.
The BASIC program can be deleted from the selection list.
This is only for iPad within portlait because of screen size.
//------------------------------------------------
/* ファイルの一覧表示と削除を行うプログラム
/* サンプルのようでいて、実は実用プログラムである
/* File list display and delete program
/* This is sample program and this is practical program actually.
//------------------------------------------------
// for X-BASIC for iOS v2.1
// 初期化 / initialize
font("IPAGothic")
int fzenhan
int WX=64:if deviceType()<>1 then WX=48
int WY=width(WX,,fzenhan)
int xw=1:/* 全角1文字の桁数 / zenkaku 1 character columus
if fzenhan then xw=2
// タッチキー位置 / touch key area
int tx=WX-20:// <WX/2にすること
int ty=3
//
// 画面作成 / screen make
int lns=20:// 表示行数 / display lines
if lns>=WY-2 then lns=WY-2
makeScreen()
//
// 全ファイルリストを得る / get all file list
dim str fileList(256):// ()内は扱える最大ファイル数
int allcnt
str ext="":// 全ファイルを示す拡張子 / extension for all files
//
// 初期ファイル検索 / initial file search
int top:// 表示している先頭行要素番号:fileList(top)
// 表示範囲は(top)〜(top+lns-1)
int cur:// カーソル位置:0〜lns-1
searchFiles(ext)
tcolor(-THWHITE,0,0,255)
int page=0
int fafterMessage=NO
//
repeat
int top0=top,cur0=cur
int fdel=NO
str ext0=ext
//
int ky=inkey()
switch ky
// カーソル移動 / cursor move
case '8'
// カーソル上 / cursor up
if fafterMessage then messageDisp("")
if cur=0 then {
if top>0 then top=top-1
} else {
cur=cur-1
}
break
case '2'
// カーソル下 / cursor down
if fafterMessage then messageDisp("")
if cur=lns-1 then {
if top+lns<allcnt then top=top+1
} else {
if top+cur<allcnt-1 then cur=cur+1
}
break
// ページ単位移動 / page move
case '4'
// 前ページ / prev. page
if fafterMessage then messageDisp("")
if allcnt>lns then {
// ページ切り替えが可能なとき / When paging is enabled
top=top-(lns-1):// 1行残す / left 1 line
if top<0 then top=0 else page=page-1
}
break
case '6'
// 次ページ / next page
if fafterMessage then messageDisp("")
if allcnt>lns then {
// ページ切り替えが可能なとき / When paging is enabled
top=top+(lns-1):// 1行残す / left 1 line
if top+lns>allcnt then {
top=allcnt-lns
} else {
page=page+1
}
}
break
// 削除 / delete
case 'd'
if fafterMessage then messageDisp("")
allcnt=allcnt-1
str fname=fileList(top+cur)
int ret
str title$,errmes$
dim str mn$(1)
if isLocalizeJapan() then {
mn$(0)="いいえ"
mn$(1)="はい"
} else {
mn$(0)="NO"
mn$(1)="YES"
}
if fname[strlen(fname)-1]='/' then {
// ディレクトリだったとき
if isLocalizeJapan() then {
title$="このディレクトリを削除しますか?"
errmes$="削除できません(空でない)"
} else {
title$="Delete this directory ?"
errmes$="Can't delete(Not empty)"
}
if selectMenu(title$,mn$)=1 then {
// ただし、空ディレクトリでないと削除できない
if rmdir(fname)=0 then {
fdel=YES:// 表示も変更が必要
} else {
messageDisp(errmes$+":"+fname)
}
}
} else {
// ファイルだった時
if isLocalizeJapan() then {
title$="このファイルを削除しますか?"+chr$(DISP_CTRL_LF)+fname
errmes$="削除できません"
} else {
title$="Delete this file ?"
errmes$="Can't delete"
}
if pathExtension(fname)="bas" then {
// .basファイルは消せないようにしておく(プログラムを削除するのはプログラム選択メニューから)
// Disable to delete .bas file (if you will do, do in program select menu)
messageDisp(errmes$+"(.bas):"+fname)
break
}
if selectMenu(title$,mn$)=1 then {
if fdelete(fname)=0 then {
fdel=YES:// 表示も変更が必要
} else {
messageDisp(errmes$+":"+fname)
}
}
}
break
// 拡張子変更 / change extension
case 'j'
if fafterMessage then messageDisp("")
ext="jpg"
break
case 'p'
if fafterMessage then messageDisp("")
ext="png"
break
case 'a'
if fafterMessage then messageDisp("")
ext=""
break
default
break
endswitch
if ext<>ext0 or fdel=YES then {
// 拡張子変更 / extension changed
// またはファイルの数が変わった / Or the number of files is changed
// ファイルの再検索をするが、このページの先頭は変更しなくても良い
int top1=top
int cur1=cur
searchFiles(ext)
if top1+cur1>=allcnt then {
if cur1>0 then cur=cur1-1:// 一番後ろを消したときは、1つ上に上げる。でもそれが最上行を消すものなら、前ページに移動する・・・のは大変なので、最初から表示しなおし
} else {
// 新しいページにまだ収まるとき
top=top1
cur=cur1
}
// ページは変わらないけど、再表示は必要
printList()
}
if top<>top0 then {
// ページが変わる / page changed
printList()
fdel=NO
} else {
if cur<>cur0 then {
// カーソル位置が変わった / cursor moved
printList1(cur0) // 元の位置を反転解除 / non-reverse old position
printList1(cur) // 新しい位置を反転 / revese new position
}
}
until ky='!'
end
//------------------------------------------------
// 関数 / functions
//------------------------------------------------
func printKeys(x;int,y;int)
// 012345678901 *2
locate(x,y+0):print "┏━┓┏━┓┏━┓┏━┓"
locate(x,y+1):print "┃←┃┃↑┃┃↓┃┃→┃"
locate(x,y+2):print "┗━┛┗━┛┗━┛┗━┛"
endfunc
func makeScreen()
// タッチキー / touch key
dim int touchNo(10) :// タッチエリア番号 / touch area number
int touchallcnt :// タッチエリア数 / the number of touch area
//
int x=0
int y=1+lns+1
printKeys(x,y)
int i=0
touchNo(inc(i))=setTouchArea(textX2Gx(x+ 0),textY2Gy(y),textX2Gx(xw*3),textY2Gy(3),'4',YES, 125,0,5,100)
touchNo(inc(i))=setTouchArea(textX2Gx(x+ 6),textY2Gy(y),textX2Gx(xw*3),textY2Gy(3),'8',YES, 125,0,5,100)
touchNo(inc(i))=setTouchArea(textX2Gx(x+12),textY2Gy(y),textX2Gx(xw*3),textY2Gy(3),'2',YES, 125,0,5,100)
touchNo(inc(i))=setTouchArea(textX2Gx(x+18),textY2Gy(y),textX2Gx(xw*3),textY2Gy(3),'6',YES, 125,0,5,100)
touchallcnt=i
// ファンクションキー / fucntion key
str exit$,ext$,prev$,next$,del$
if isLocalizeJapan() then {
exit$="終了"
ext$="全て"
prev$="前頁"
next$="後頁"
del$="削除"
} else {
exit$="exit"
ext$="all"
prev$="Prev"
next$="Next"
del$="Del"
}
setFunctionKey(0,prev$,'4')
setFunctionKey(1,next$,'6')
setFunctionKey(2," ",'?')
setFunctionKey(3,del$ ,'d')
setFunctionKey(4," ",'?')
setFunctionKey(5,"jpg",'j')
setFunctionKey(6,"png",'p')
setFunctionKey(7,ext$ ,'a')
setFunctionKey(8," ",'?')
setFunctionKey(9,exit$,'!')
setFunctionKeyBackgroundImage("funcBack.png")
displayFunctionKeyAll(YES,YES):// v2.0
endfunc
func messageDisp(mes;str)
locate(0,lns+1)
if len(mes)=0 then {
print chr$(DISP_CTRL_CLEARLINE)
fafterMessage=NO:// メッセージ表示してない / Message is not displaying
} else {
print mes
fafterMessage=YES:// メッセージ表示中 / Now message is displaying
}
endfunc
//------------------------------------------------
func printList1(i;int)
// 1行表示 / 1line display
locate(0,1+i)
if i=cur then tatrb(ATRB_REVERSE):// 選択行 / selected line
if top+i<allcnt then {
print using "###:";top+i;
print fileList(top+i);
// print lastPathComponent(fileList(top+i));
if i=cur then tatrb(ATRB_NORMAL)
}
print chr$(DISP_CTRL_CLEARLINE):// 行末まで消す / clear to end of line
endfunc
func printList()
// 画面内表示 / display in screen
int i
int max=lns
for i=0 to max-1
printList1(i)
next
locate(WX-10,0):print "page=";page
endfunc
func searchFiles(ext;str)
// 新しく表示し直すので各種ポインターをリセット
top=0 :// 表示している先頭行要素番号:fileList(top)
// 表示範囲は(top)〜(top+lns-1)
cur=0 :// カーソル位置:0〜lns-1
//
allcnt=files(fileList,"",ext,YES,FILES_ALL)
cls()
printKeys(0,1+lns+1)
//
locate(0,0)
if isLocalizeJapan() then {
print "拡張子=";ext,,
print "ファイル数=";allcnt
} else {
print "extension=";ext,,
print allcnt;" files"
}
printList()
endfunc
//------------------------------------------------
Change in V1.71 Add : Support X68000 ADPCM/M44/P16 file in a_setPlayData() Add : pic_load() and cut_load() Add : Regular expression can use in files() Add : Coordinate check in bitmap Add : bitmap function (line,box,fill,circle,paint,get,put) Fix : Manual mistake Fix : The print statement which is immediate after cls may not display(only V1.6). Fix : Error No. and its message was mismatch Fix : Sometime, error line does not match to the line that caused the error in fact. Fix : Priority of the key display screen is not the highest. Fix : Minor bug Delete : BASIC program import function(even via ZIP) ; Mentioned by Apple's review.
For the last point I'll make a little supplement.
In V1.60, there were import feature of BASIC program via email, etc.. However, this function was rejected in this review.
"Be any form, you must not import the executable file from the outside" This is the reason.
It is not only native executable file but also includes script files that do not work unless like BASIC, is that app.
This is not allowed only import a single file but also import with ZIP file.
"I programmed that bas file in zip is not expand."Mention them, so I finally passed the review.
So, I could not leave that feature.
In addition,About the data such as audio or image can be imported as usual.
One short program.
This is the Tower of Hanoi.
It displays the solution method of the Tower of Hanoi.
It is often used as an example of a recursive call.
See also here about "Tower of Hanoi".
https://en.wikipedia.org/wiki/Tower_of_Hanoi
/* Tower of Hanoi for X68
// Oh!X 1988/5 p54
int n
str a="A",b="B",c="C"
while 1
input "n(0=end)=" , n
if n=0 then break
hanoi( n , a ,c , b)
print
endwhile
end
func hanoi(n;int,a;str,c;str,b;str)
if n>0 then {
hanoi(n-1,a,b,c)
print a; "->" ; c; ",";
hanoi(n-1,b,c,a)
}
endfunc
This is the "sieve of Eratosthenes" so-called.
It can find the prime numbers up to 10000.
int fscroll=YES:// YES=scroll(V2.0 only) / NO=page(all version)
if isLocalizeJapan() then {
print "エラトステネスのふるい(〜10000)"
} else {
print "Sieve of Eratosthenes(to 10000)"
}
print "start:";time$
//
int i,p
int max=10000
dim nt(10000):/* At definition , initial value is 0(=NO)
for i=2 to max/2
nt(i*2)=YES
next
p=3
while p*p<=max
for i=p to max/p
nt(i*p)=YES
i=i+1:/* step2
next
p=p+1
while nt(p):p=p+1:endwhile
endwhile
int cnt=0
for i=2 to max
if nt(i)=0 then {
print i,
if not fscroll then {
inc(cnt)
if cnt>=30*8 then {
// Because X-BASIC for iOS can not scroll text screen, it continues to display with clearing text screen every certain number.
hitKey()
cls()
cnt=0
}
}
}
next
print
print "end:";time$
end
//---------
func hitKey()
setFunctionKey(0,localizedString("ここを押してください","Hit This Button"),'!')
displayFunctionKey(YES,0,0)
while inkey()=0
endwhile
cls()
displayFunctionKey(NO,0,0)
endfunc
//---------
func str localizedString(js;str,es;str)
if isLocalizeJapan() then return(js)
return (es)
endfunc
//---------
"Ramdomwalk" simulates the footsteps of a drunken man (^_^;).
There are rows which has line number or does not have.
This program also serves as a test of the "Delete line number".
All line number are automatically deleted by the X-BASIC for iOS.
10 /*
20 /* Random walk
30 /* Converted from http://d.hatena.ne.jp/x68000forever/
width(0)
int wx,wy
getWidth(wx,wy)
vpage(B_TPAGE or B_GPAGE0,YES)
width(32)
cls():wipe()
randomise(time())
50 int ix0,iy0,iscl
60 float d,ox,oy,xg,yg,x,y,t,r=0.05#
70 /*
80 ix0=wx/2
90 iy0=wy/2
100 iscl=wx/4
110 /*
120 x=0:xg=ix0
130 y=0:yg=iy0
140 /*
150 while xg>0 and xg<wx and yg>0 and yg<wy
160 /*
170 d=rnd()
locate(0,0):print d;" ";
180 t=pi(d*2)
190 /*
200 x=x+r*cos(t)
210 y=y+r*sin(t)
220 /*
230 ox=xg:xg=ix0+iscl*x
240 oy=yg:yg=iy0+iscl*y
250 /*
gcolor(191*d*(256/32),(rand() mod (256-64))+64,(rand() mod (256-32))+32,220)
260 line(ox,oy,xg,yg)
270 /*
280 endwhile
290 end
//
1000 // 実は行番号有りテスト(行番号は全て削除される。ただし、先頭行に行番号がないとだめ)
2000 // line numbers test (line numbers remove all.)
This program draws a self square fractal with using bitmap.
This draws the shape on the bitmap once
It displayed on the screen after the completion.
By doing this method, it draws in just 40 seconds (iPad3).
In addition, it also tests other bitmap functions.
References : Oh!X 1988 March "Introductory of X68000BASIC" Akira Nakamori
// Self square fractal drawing
// bitmap use type
// fdirect=NO
// And tile paste
// And bitmap functions test
// for X-BASIC for iOS v2.0
width(64)
//
vpriority(TPAGE,GPAGE0,GPAGE1,GPAGE2,GPAGE3)
vpage(B_TPAGE+B_GPAGE0+B_GPAGE1+B_GPAGE2+B_GPAGE3,YES)
apage(GPAGE0)
//
int wx=512,wy=512
if YES then {://------------------------------------
bitmapOpen(wx,wy)
drawFractal(wx,wy,0)
bitmapImgLoad(128,128,wx,wy):// wx,wy is translated to float
bitmapClose()
//
hitKey()
wipe()
wx=128
wy=128
dim int getAry(128*128)
//int size1
//int youso=sizeofArray(getAry,size1)
//print "number of elements=";youso;"/1element size=";size1
bitmapOpen(wx,wy)
drawFractal(wx,wy,5)
bitmapTileImgLoad(128.0,128.0,512.0,512.0)
bitmapGet(0,0,64,64,getAry)
bitmapClose()
//
hitKey()
wipe()
wx=512:wy=512
bitmapOpen(wx,wy)
int i,sx,sy,ex,ey,col,h,s
for i=0 to 10
h=rnd()*360
s=rnd()*256
col=hsv(h,s,255,255)
//
sx=rand() mod wx
ex=rand() mod wx
sy=rand() mod wy
ey=rand() mod wy
bitmapLine(sx,sy,ex,ey,col)
//
sx=rand() mod wx
ex=rand() mod wx
sy=rand() mod wy
ey=rand() mod wy
bitmapBox(sx,sy,ex,ey,col)
//
sx=rand() mod wx
ex=rand() mod wx
sy=rand() mod wy
ey=rand() mod wy
bitmapFill(sx,sy,ex,ey,col)
//
sx=rand() mod wx
sy=rand() mod wy
ex=rand() mod 100+1:// radius
locate(0,i):print "x,y,r=";sx,sy,ex
bitmapCircle(sx,sy,ex,col)
bitmapPaint(sx,sy,col)
next
bitmapPut(200,200,200+64,200+64,getAry)
bitmapImgLoad(128,128,wx,wy):// wx,wy is translated to float
bitmapClose()
//
hitKey()
}://------------------------------------
if YES then {://------------------------------------
// Test for bitmapImageFile()
// Please write exist image file name
wipe()
wx=512:wy=512
bitmapOpen(wx,wy)
//
bitmapImageFile("IMG1.JPG",10,10,256,256)
bitmapImgLoad(128,128,wx,wy):// wx,wy is translated to float
hitKey()
//
bitmapImageFile("IMG2.PIC")
bitmapImgLoad(128,128,wx,wy):// wx,wy is translated to float
hitKey()
//
bitmapImageFile("GAROU.CUT")
bitmapImgLoad(128,128,wx,wy):// wx,wy is translated to float
//
bitmapClose()
}://------------------------------------
//
end
//---------
func drawFractal(wx;int,wy;int,ty;int)
locate(0,ty+0):print "wx*wy=";wx;"*";wy
locate(0,ty+1):print "start=";time$
//
int MAXREP=50
int MAXDOT=wx
int MAXCOL=255
float remin=-0.5#
float remax= 0.5#
float immin=-0.5#
float immax= 0.5#
float recon=-0.04#
float imcon=-0.695#
int rep,ix,iy
float x,y,re,im,dx,dy
//
dx=(remax-remin)/MAXDOT
dy=(immax-immin)/MAXDOT
//
for iy=0 to MAXDOT-1
locate(0,ty+2):print "line=";iy
for ix=0 to MAXDOT-1
x=remin+ix*dx
y=immin+iy*dy
for rep=0 to MAXREP
re=x*x-y*y+recon
im=2#*x*y+imcon
if ((re*re+im*im)>4#) then break
x=re:y=im
next
int c=(rep mod MAXCOL)*4
bitmapPset(ix,iy,c,c,c,255)
//gcolor(c,c,c,255)
//pset(ix,iy)
next
next
locate(0,ty+2):print "end=";time$
endfunc
//---------
func hitKey()
setFunctionKey(0,localizedString("ここを押してください","Hit This Button"),'!')
displayFunctionKey(YES,0,0)
while inkey()=0
endwhile
cls()
displayFunctionKey(NO,0,0)
endfunc
//---------
func str localizedString(js;str,es;str)
if isLocalizeJapan() then return(js)
return (es)
endfunc
//---------
This program draws a self square fractal.
In V1.6, screen drawing becomes so faster, it can draw in only 105 seconds (iPad3).
By the way, At 512 x 512 size, it took about 1 hour 25 minute on the iPad3 with V1.5.
Peke-BASIC took about 3.5 hours and X-BASIC/68 seems to take more than 6 hours.
References : Oh!X 1988 March "Introductory of X68000BASIC" Akira Nakamori
// Self square fractal drawing
// pset() use type
int wx,wy
width(0)
getWidth(wx,wy):/* get graphic screen size
width(64)
// same as X68000 size
if wx>=512 then wx=512
if wy>=512 then wy=512
//
locate(0,0):print "wx*wy=";wx;"*";wy
locate(0,1):print "start=";time$
vpriority(TPAGE,GPAGE0,GPAGE1,GPAGE2,GPAGE3)
vpage(B_TPAGE or B_GPAGE0 or B_GPAGE1 or B_GPAGE2 or B_GPAGE3,YES)
apage(GPAGE0)
int MAXREP=50
int MAXDOT=wx
int MAXCOL=255
float remin=-0.5#
float remax= 0.5#
float immin=-0.5#
float immax= 0.5#
float recon=-0.04#
float imcon=-0.695#
int rep,ix,iy
float x,y,re,im,dx,dy
//
dx=(remax-remin)/MAXDOT
dy=(immax-immin)/MAXDOT
/*
for iy=0 to MAXDOT-1
locate(0,2):print "line=";iy
for ix=0 to MAXDOT-1
x=remin+ix*dx
y=immin+iy*dy
for rep=0 to MAXREP
re=x*x-y*y+recon
im=2#*x*y+imcon
if ((re*re+im*im)>4#) then break
x=re:y=im
next
int c=(rep mod MAXCOL)*4
gcolor(c,c,c,255)
pset(ix,iy)
next
next
locate(0,2):print "end=";time$
//
end
This is the development status of the next version of "X-BASIC for iOS".
If you have reporting or requirements, please put a comment in this post.
V1.60
* Change : Faster screen drawing
* Fix : The error line number may be shifted
* Fix : Some images for Manual are nothing.
* Fix : Help contents is old in iPod touch and iPhone.
+ Add : Enable to be specified by the composite RGB value
+ Add : rgb()/hsv()/x68Color2iOSColor()
+ Add : wait()
+ Add : pset()
+ Add : bitmap functions
+ Add : picLoader/cutLoader()
+ Add : using "%"
* Fix : manual misstake
* Fix : text color color was not affect in input()/inputWithPlaceholder()
* Fix : Calling selectMenu/2() immediately after touch, it continues key repeat.
* Fix : bingo.bas's bugs
* Fix : minor bugs
V1.71 in sale
Add : Support X68000 ADPCM/M44/P16 file in a_setPlayData()
Add : pic_load() and cut_load()
Add : Regular expression can use in files()
Add : Coordinate check in bitmap
Add : bitmap function (line,box,fill,circle,paint,get,put)
Fix : Manual mistake
Fix : The print statement which is immediate after cls may not display(only V1.6).
Fix : Error No. and its message was mismatch
Fix : Sometime, error line does not match to the line that caused the error in fact.
Fix : Priority of the key display screen is not the highest.
Fix : Minor bug
Delete : BASIC program import function(even via ZIP) ; Mentioned by Apple's review.
V1.80 (no release)
Add : AirPrint program list
Add : RUN screen hard copy function
Add : Screen hard copy function
Add : key screen is reproduce at RUN screen display
Fix : beep2(13) sound is illegal
V2.00(Coming soon)
Add : sprite and BG functions
Add : Enable to display two-stage function key in the portrait of iPod touch and iPhone.
Add : bitmapImageFile()
Add : bitmap functions can use same area as usual graphics functions.
Add : Scroll in text screen
Fix : osVersion() sometime returns illegal value.
Fix : Display of float value is not same as X-BASIC/68.
Fix : It is not rounded when you display float with no decimal digit in the "using"
Fix : Illegal setting at keyRepeatTime()
Fix : At 3.5 inches devices (iPod touch 4 and iPhone 4), the bottom of the screen is cut off.
Fix : tborder() is not display until print any contents.
Fix : It may fall at using float arrays.
Fix : The startAngle and endAngle of circle() is misinterpreted.
Fix : It may fall with repeating the selection of program
Fix : minor bugs
Fix : Bugs of sample BASIC programs
Fix : Manual mistake(many)
Another development status
* Text Screen Scroll : Proves to be difficult
・・・March-13/2013
I decided to suspend development for iOS as main job.
Because I had no profit at all.
Application support and update development will do as a hobby.
At X-BASIC for ios, the V1.8 will be release.
But the implementation of sprite function is completely undecided.
It should be noted that, for the recovery of development costs, the price of the app will be maintained for the time being.
Sorry.
・・・April-17/2013
I resume development of V1.80, and it finished.
At the same time, I started the development of V2.00.
However, It is not a core business, so it takes time.
I am here also publish the sample program of X-BASIC for iOS.
Some samples are what has been built-in.
・・・September 9/2013
I make ".bc file expand tool".
When you use this program, you are able to import BASIC program easily.
But ".bc file expand tool". itsself must be import with following way.
・・・
Each program is a little cumbersome, please input in the following way.
Some program needs data file. In that case also import the Zip file.
// Data files imports from another application
"X-BASIC for iOS" can import each sound file(such as wav/aiff) or .zip file from another applications which has file export function.
Each image file (such as jpeg/png) must import with zip file because of iOS's constraint.
Each image file (such as jpeg/png) must import with zip file due to the constraint of iOS.
Important:
The import function of the bas program (there were up to V1.6), had to be removed with pointing out by Apple.
You can not import .bas file even using ZIP file.
Sorry, please understand.
If the zip is to import it automatically expands all the files contained therein.
You do not set a password on zip file. It is not able to expand.
If the zip with a directory, create a directory to store the user area.
Basically please use only one level directory.
Deep directory hierarchy, may not be able to access.
example test1.zip-test1.wav,test1.png,... no directory
test2.zip-test2/test2.wav with directory
test2.png
...
Therefore, you will need to describe with directory name to access the files in the directory.
("X-BASIC for iOS" has no current directry concept. Suffice it to say, the root is always current.)
example fopen("test2/test2.png","r") right
fopen("test2.png","r") wrong
During import, if a file with the same name already exists, the file name will be changed automatically.
Please be careful.
Example : Import from Mail in iOS.
Receive the mail attached with each sound file(s) or .zip file(s) in iOS device that is installed "X-BASIC for iOS".
Touch attached file icon for a while.
Then, it opens a pop-up to export to the application that supports the file.
Note:
The attachment may not be saved to the device until you will tap actually
(This is a feature of iOS mail).
If the line around attachment is dotted, it is not downloaded.
If the line around attachment is solid, it is already downloaded.
You must be in the download state if you want to export to the X-BASIC.
Tap "Open in X-BASIC"
In this procedure, the import is completed.
I was rejected the BASIC program import function at the time of the review V1.70 by Apple.
Therefore, It was forced to become this way.
Apple has a policy that does not allow to import any execution files including BASIC program source.
(Data files are available).
But I think BASIC source is kind of script that works only in the application...
Samples are guaranteed to work only with the latest published version basically.
Some parts may seem to garbled. The garbled character are Japanese character.
However, all program supports both English and Japanese , so it is not a problem.
If you paste on the X-BASIC for iOS, list is displayed in the correct character.
Part of the comment in the program is Japanese only.
In addition, the program which has list may be also modify or upgraded.
As long as it is not very important update, I do not correct the published list.
(Because it takes time terribly.)
Sorry to trouble you, please get the latest version of the Zip file to which it is linked.
Here is a blog for the support of the X-BASIC for iOS.
I will post information about support for X-BASIC for iOS.
Sample program
How to use
Bug(s) information
Updates information
At the same time, you can put a comment and I will answer your questions as well.
In addition, only I am doing the development or support.
Therefore, I think there is probably also to be delayed reply.
Sorry, please understand.
And I'm not good at English, there was a strange sentence, please reading appropriately.
P.S.
At first, I will variously change the contents of the article.
Because it is a transient state until it finds a convenient way,
Please acknowledge it.