Basic course for newbies

Página 8/11
1 | 2 | 3 | 4 | 5 | 6 | 7 | | 9 | 10 | 11

Por NYYRIKKI

Enlighted (5939)

imagem de NYYRIKKI

28-12-2013, 23:13

Yes, highlight is also one of those things that are not really supported by MSX-BASIC, but see the few changes that I made to your program:

5 DEFINT A-Z
10 CLEAR 2000:SCREEN 0:WIDTH 80:COLOR 15,0,0:KEY OFF
20 DIM FO$(1000)
30 FM$="????????.???"
40 DA$="0E11110E12C51100C10E1ACD7DF3C11180C0CD7DF332F8F7C9"
50 AD=&HC080:POKE AD,0
60 FOR I=1 TO 12:AD=AD-(I<>10):POKE AD,ASC(MID$(FM$,I,1)):NEXT I
70 FOR I=&HC08C TO &HC0C0:POKE I,0:NEXT I
75 FOR I=2048 TO 2288:VPOKE I,0:NEXT I
76 VDP(13)=&HA8 ' Color 10 on color 8 (yellow on red)
77 VDP(14)=16
80 FOR I=0 TO 25:POKE &HC000+I,VAL("&H"+MID$(DA$,I*2+1,2)):NEXT I
90 DEFUSR=&HC000:DEFUSR1=&HC003
100 IF USR(0)>0 THEN END
110 FOR I=1 TO 12
120 FO$(COUNTER)=FO$(COUNTER) + CHR$(PEEK(&HC100+I))
130 IF I=8 THEN FO$(COUNTER)=FO$(COUNTER)+ "."
140 NEXT I
150 IF USR1(0)=0 THEN COUNTER = COUNTER +1: GOTO 110
160 SCREEN 0:WIDTH80:COLOR15,0,0:CLS
170 FOR I=0 TO COUNTER
180 LOCATE X,Y :PRINT FO$(I)
190 X=X+16:IF X>70 THEN Y=Y+1:X=0
200 NEXT I
210 DIM ST,SX,SY,AX,AY
211 GOTO 280
220 ST = STICK(0)
230 IF ST=0 THEN 220
231 VPOKE AD,0:VPOKE AD+1,0
240 IF ST=1 THEN SY=SY-1:IF SY=<0 THEN SY=0
250 IF ST=5 THEN SY=SY+1:IF SY=>Y THEN SY=Y
260 IF ST=7 THEN SX=SX-1:IF SX=<0 THEN SX=0
270 IF ST=3 THEN SX=SX+1:IF SX=>4 THEN SX=4
280 AD=2048+SX*2+SY*10:VPOKE AD,255:VPOKE AD+1,&B11110000
290 TIME=0:FOR I=0 TO 8:I=TIME:NEXT I
310 GOTO 220

Por edoz

Prophet (2443)

imagem de edoz

28-12-2013, 23:46

Thanks again! .. it seems a bit better! I will try it! There are some changes I don't understand.. but maybe playing around will help a lot!

280 AD=2048+SX*2+SY*10:VPOKE AD,255:VPOKE AD+1,&B11110000

I was wondering. The VPOKE will do something with the highlight, I think Wink but what is the meaning for the number 2048 ? It seems that it had something to-do with a binary count ? Where are the VDP commands for ?

Por Vampier

Prophet (2397)

imagem de Vampier

29-12-2013, 21:04

100 SCREEN 1:WIDTH32:KEYOFF
110 'adjusting fonts
120 'lets adjust the letter "a"
130 PRINT ASC("a")*8
140 'this gives the value 776
150 'now we poke around in the video memory
160 VPOKE 776,&B11111111
170 VPOKE 777,&B10000001
180 VPOKE 778,&B10111101
190 VPOKE 779,&B10100101
200 VPOKE 780,&B10100101
210 VPOKE 781,&B10111101
220 VPOKE 782,&B10000001
230 VPOKE 783,&B11111111
235 'output to screen
240 PRINT "a"

Por edoz

Prophet (2443)

imagem de edoz

30-12-2013, 10:31

Vampier wrote:
100 SCREEN 1:WIDTH32:KEYOFF
110 'adjusting fonts
120 'lets adjust the letter "a"
130 PRINT ASC("a")*8
140 'this gives the value 776
150 'now we poke around in the video memory
160 VPOKE 776,&B11111111
170 VPOKE 777,&B10000001
180 VPOKE 778,&B10111101
190 VPOKE 779,&B10100101
200 VPOKE 780,&B10100101
210 VPOKE 781,&B10111101
220 VPOKE 782,&B10000001
230 VPOKE 783,&B11111111
235 'output to screen
240 PRINT "a"

Who! That's a cool explaination! So if i understand this code right i can change the letter A in what i want!
I got the god feeling Big smile

I just played with it .. but it is not working in screen 0 ?

Por GhostwriterP

Hero (665)

imagem de GhostwriterP

30-12-2013, 11:01

In screen 0 the patterns start at a different address, IIRC &h800, so do VPOKE &h800+776,&b11111111 that should do it.
Edit: at least for width 40 mode, for width 80 you need to add &h1000 Wink

Por Poltergeist

Champion (278)

imagem de Poltergeist

30-12-2013, 11:15

These addresses can be found using the BASE command: http://www.msx.org/wiki/BASE. Also bear in mind that screen 0 only uses 6 pixels instead of 8. You need the charactertable, by the way...

Por edoz

Prophet (2443)

imagem de edoz

30-12-2013, 11:30

i just found out about the 6 pixels Wink but it works!
About the base. Can anyone explain a bit more. If i type in screen0 ? base(2) i got a result number 4096, in screen 1 i got 2048 as a result. But how do i translate that to a vpoke command ?

Por Poltergeist

Champion (278)

imagem de Poltergeist

30-12-2013, 12:53

The number you're getting is the startaddress for that specific table. If you want to know where the charactertable starts in screen 0, width 40, first set the width to 40 (or less), then use base(2). If you want to know it for width 80, set the width to 80, and do a base(2) again. The first will give you a value of 2048, the second of 4096. However, if you want to know it for screen 1, you need to use base(7) as 1*5+2 is 7. (see the calculation on the wikipage)

That number what you're getting is the first address for that table. Each character consists of 8 bytes, and the first character starts on that address. If you want to change the capital A, for example, you need the ascii value for A (which is 65), multiply that by 8 (which is 520, and add that to the base address. This address, and the 7 next addresses make up the A character. You can read the values with VPEEK

Simple example:

1 ' show the letter A in bitmap
10 screen0:width 40:ad=base(2) 'the base address for the characterset in screen 0
20 A=asc("A")*8
30 for co=0 to 7
40 print right$("0000000"+bin$(vpeek(ad+a+co)),8)
50 next co

Por edoz

Prophet (2443)

imagem de edoz

30-12-2013, 13:38

10 DEFINT A-Z
20 CLEAR 2000:SCREEN 0:WIDTH 80:COLOR 15,0,0:KEY OFF
30 DIM FO$(1000)
40 FM$="????????.???"
50 DA$="0E11110E12C51100C10E1ACD7DF3C11180C0CD7DF332F8F7C9"
60 AD=&HC080:POKE AD,0
70 FOR I=1 TO 12:AD=AD-(I<>10):POKE AD,ASC(MID$(FM$,I,1)):NEXT I
80 FOR I=&HC08C TO &HC0C0:POKE I,0:NEXT I
90 FOR I=2048 TO 2288:VPOKE I,0:NEXT I
100 VDP(13)=&HA8 ' Color 10 on color 8 (yellow on red)
110 VDP(14)=16
120 FOR I=0 TO 25:POKE &HC000+I,VAL("&H"+MID$(DA$,I*2+1,2)):NEXT I
130 DEFUSR=&HC000:DEFUSR1=&HC003
140 IF USR(0)>0 THEN END
150 FOR I=1 TO 12
160 FO$(COUNTER)=FO$(COUNTER) + CHR$(PEEK(&HC100+I))
170 IF I=8 THEN FO$(COUNTER)=FO$(COUNTER)+ "."
180 NEXT I
190 IF USR1(0)=0 THEN COUNTER = COUNTER +1: GOTO 150
200 SCREEN 0:WIDTH80:COLOR15,0,0:CLS
210 FOR I=0 TO COUNTER
220 LOCATE X,Y :PRINT FO$(I)
230 X=X+16:IF X>70 THEN Y=Y+1:X=0
240 NEXT I
250 DIM ST,SX,SY,AX,AY
260 GOTO 340
270 ST = STICK(0)
280 IF ST=0 THEN 270
290 VPOKE AD,0:VPOKE AD+1,0
300 IF ST=1 THEN SY=SY-1:IF SY=<0 THEN SY=0
310 IF ST=5 THEN SY=SY+1:IF SY=>Y THEN SY=Y
320 IF ST=7 THEN SX=SX-1:IF SX=<0 THEN SX=0
330 IF ST=3 THEN SX=SX+1:IF SX=>4 THEN SX=4
340 AD=2048+SX*2+SY*10:VPOKE AD,255:VPOKE AD+1,&B11110000
350 LOCATE 0,22: PRINT SX
360 LOCATE 4,22: PRINT SY
370 LOCATE 12,22 : PRINT "SELECTED FILE: ";FO$(SX+(SY*5))
390 TIME=0:FOR I=0 TO 8:I=TIME:NEXT I
400 GOTO 270

350 LOCATE 0,22: PRINT SX
360 LOCATE 4,22: PRINT SY
370 LOCATE 12,22 : PRINT "SELECTED FILE: ";FO$(SX+(SY*5))

Is this a good way to get the selected filename ?

Por edoz

Prophet (2443)

imagem de edoz

30-12-2013, 17:11

Ok, I added the Sega loader instructions to the basic code. It seems to be working. Next is to make it possible to toggle the SMS options etc. for each game. And to save it for every game (They are now all default.) What is the best way to do this ? To avoid delay in speed. Save the setting for each game when starting the game ? And load all the game default at the begin when the loader is started ?

The first part (loading the files in to the array) takes some time in basic. Is there a way to speed it up a bit ?

10 DEFINT A-Z
20 CLEAR 2000:SCREEN 0:WIDTH 80:COLOR 15,0,0:KEY OFF:CLS
30 PRINT "Loading files in basic":Q1=22
40 DIM FO$(1000)
50 FM$="????????.???"
60 DA$="0E11110E12C51100C10E1ACD7DF3C11180C0CD7DF332F8F7C9"
70 AD=&HC080:POKE AD,0
80 FOR I=1 TO 12:AD=AD-(I<>10):POKE AD,ASC(MID$(FM$,I,1)):NEXT I
90 FOR I=&HC08C TO &HC0C0:POKE I,0:NEXT I
100 FOR I=2048 TO 2288:VPOKE I,0:NEXT I
110 VDP(13)=&HA8 ' Color 10 on color 8 (yellow on red)
120 VDP(14)=16
130 FOR I=0 TO 25:POKE &HC000+I,VAL("&H"+MID$(DA$,I*2+1,2)):NEXT I
140 DEFUSR=&HC000:DEFUSR1=&HC003
150 IF USR(0)>0 THEN END
160 FOR I=1 TO 12
170 FO$(COUNTER)=FO$(COUNTER) + CHR$(PEEK(&HC100+I))
180 IF I=8 THEN FO$(COUNTER)=FO$(COUNTER)+ "."
190 NEXT I
200 Q1=Q1+1
210 LOCATE Q1,Q2 :PRINT".":IF Q1=>80 THEN Q1=0:Q2=Q2+1
220 IF USR1(0)=0 THEN COUNTER = COUNTER +1: GOTO 160
230 SCREEN 0:WIDTH80:COLOR15,0,0:CLS
240 FOR I=0 TO COUNTER
250 LOCATE X,Y :PRINT FO$(I)
260 X=X+16:IF X>70 THEN Y=Y+1:X=0
270 NEXT I
280 DIM ST,SX,SY,AX,AY
290 GOTO 380
300 ST = STICK(0)
310 IF STRIG(0)=-1 THEN N$=FO$(SX+(SY*5)):GOTO 460
320 IF ST=0 THEN 300
330 VPOKE AD,0:VPOKE AD+1,0
340 IF ST=1 THEN SY=SY-1:IF SY=<0 THEN SY=0
350 IF ST=5 THEN SY=SY+1:IF SY=>Y THEN SY=Y
360 IF ST=7 THEN SX=SX-1:IF SX=<0 THEN SX=0
370 IF ST=3 THEN SX=SX+1:IF SX=>4 THEN SX=4
380 AD=2048+SX*2+SY*10:VPOKE AD,255:VPOKE AD+1,&B11110000
390 LOCATE 0,22: PRINT SX
400 LOCATE 4,22: PRINT SY
410 LOCATE 12,22 : PRINT "SELECTED FILE: ";FO$(SX+(SY*5))
420 LOCATE 12,38
430 IF STRIG(0)=-1 THEN N$=FO$(SX+(SY*5):GOTO 460
440 TIME=0:FOR I=0 TO 8:I=TIME:NEXT I
450 GOTO 300
460 ' (base address and interrupt off)
470 IF PEEK(&H2D)=0 THEN OUT &H2A,33:OUT &H2B,1:OUT &H2A,&H1D:OUT &H2B,&H99:SCREEN 0:WIDTH 40 ELSE SCREEN 0:WIDTH 80
480 V=0  'Video system: 0=PAL  1=NTSC
490 H=0  'Refresh freq: 0=50Hz 1=60Hz
500 F=1  'FM-Pac usage: 0=No   1=Yes
510 R=0  'RGB status  : 0=RGB  1=CVBS
520 OV=1 'Overlay     : 2=Key  7=All1:3
530 'Turbo-R masks IO &HDC, alternative
540 ' IO is used when K=64
550 K=64 'Kanji       : 64=Yes 128=Norm
560 S=1:N=0
570 S=2
580 REM PRINT "Loading game: ";N$
590 D$=LEFT$(N$+"       ",8)
600 BLOAD "SONIQ.BIN"
610 POKE &HC5FE,H*32+V*64
620 POKE &HC5FF,OV+K+F*16+F*32
630 FOR A=1 TO 8:POKE &HC5FF+A,ASC(MID$(D$,A,1)):NEXT:DEF USR=&HC000:A=USR(0)
640 OUT &H2A,33:OUT &H2B,INP(&H2B) OR 1:OUT &H2A,&H1D:OUT &H2B,&H99
650 OUT &H2A,31:I=INP(&H2B)

Página 8/11
1 | 2 | 3 | 4 | 5 | 6 | 7 | | 9 | 10 | 11