English Amiga Board

English Amiga Board (https://eab.abime.net/index.php)
-   Coders. Blitz Basic (https://eab.abime.net/forumdisplay.php?f=126)
-   -   Blitz Basic 2 basics (https://eab.abime.net/showthread.php?t=86431)

Retro1234 17 March 2017 11:22

Blitz Basic 2 basics
 
This thread is for questions on the very basics.

Retro1234 17 March 2017 11:23

First questions using Inkey$ with raw key codes How?

Daedalus 17 March 2017 11:32

Inkey$ is used to take input from the current input stream, but it won't work in the Shell if that's what you're trying to do? Edit$ is used instead for taking a whole line. Also, from memory, Inkey$ gives you a cooked key, nor a rawkey, though I don't think that would make much of a difference.


What exactly are you trying to do?

Retro1234 17 March 2017 11:39

So im in Blitz mode and want to control my objects from keyboard instead of joystick

A$=inkey
If a$="a"
print " a"
End if
Repeat

but instead of a$="a" I want to use the Raw keycodes

Daedalus 17 March 2017 11:46

Ah, ok. Well then Inkey$ probably isn't what you want then. You'll need to use the RawStatus() function and provide it with the rawkey code you're looking for. For example:

Code:

If RawStatus($45)
  Print "Escape pressed!"
End If

I think you need to turn on key reading in Blitz mode too if you haven't already done that.

Edit: Rawkey codes are laid out on a page at the back of the Blitz manual, but appear to be missing from the online manual. The codes can be found here in the first column.

Retro1234 17 March 2017 11:53

Brilliant ill try it out

Daedalus 17 March 2017 11:55

Cool. Apparently you also need to have the command

Blitzkeys On

after you go into Blitz mode to enable reading of the keyboard...

Retro1234 17 March 2017 11:56

Excellent

Retro1234 17 March 2017 12:34

We have a palette
0=Purple
1=Black
2=White
3=Orange

Cls 3 - an Orange Screen
Using Print Command
Change the Colour of the Text to White 2 and the border around the text to Black 1?

Daedalus 17 March 2017 12:38

Use the Colour command before the Print command:

Colour 2, 1

should work... You don't have to provide the second parameter, in which case the background will be whatever the background colour is on the bitmap.

Retro1234 17 March 2017 12:41

Quote:

Originally Posted by Daedalus (Post 1147408)
Use the Colour command before the Print command:

Colour 2, 1

should work... You don't have to provide the second parameter, in which case the background will be whatever the background colour is on the bitmap.

Excellent and the Colour command is only for use with the print command?

I hope this thread will be helpful for other people as well.

Daedalus 17 March 2017 12:44

Yep, it's only for when you're outputting text to a bitmap specifically.

Retro1234 17 March 2017 12:45

Thanks again - now what question next:spin:confused

MickGyver 17 March 2017 15:12

I have a question, what is the fastest method of using blockscroll without getting flicker? Now I use double buffering and BitMapCopy but is there a better way? This is probably a very stupid way of doing it

Daedalus 17 March 2017 16:31

Hmmm, I don't really know about blockscrolling as I haven't really used it... Are you sure you're synchronising with the vertical blank though? What part of the display flickers?

MickGyver 17 March 2017 16:45

The whole screen flickers if I don't use double buffering, but the way I do double buffering now is probably very inefficient. I'm trying to figure out how to do 8way scrolling with a large tilemap, I haven't found any example how to do this. I was thinking of using blockscroll and drawing only blocks coming in. It's working in one direction now but probably very inefficient. This is my code:

Code:

; TILEMAP TEST

#bm_map_width = 22
#bm_map_height = 14

; Set default type to word
DEFTYPE .w

BitMap 0,352,224,4 ; Create bitmap1
BitMap 1,352,224,4 ; Create bitmap2
BitMap 2,192,128,4 ; Bitmap for tiles, create and set as used

LoadBitMap 2,"set.iff"
LoadPalette 0,"set.iff"

; Get shapes from the bitmap containing tiles (increase the max number of shapes in compiler options to 200)
i = 0
For y = 0 To 7
  For x = 0 To 11
    GetaShape i, x LSL 4, y LSL 4, 16, 16
    i = i + 1
  Next
Next

; Free the shapes bitmap
Free BitMap 2

; Use bitmap 0 (shown on screen)
Use BitMap 0

; Read the tile map
map_xmax = 0
map_ymax = 0
If ReadFile(0,"tilemap102x74.map")
  ReadMem 0, &map_xmax, 2 ; width in tiles
  ReadMem 0, &map_ymax, 2 ; height in tiles
  map_xmax-1 ; same as map_xmax = map_xmax - 1;
  map_ymax-1
  Dim mapa.b(map_xmax, map_ymax)
  ReadMem 0, &mapa.b(0,0), (map_xmax+1)*(map_ymax+1)
  CloseFile 0
EndIf

BLITZ ; Go into blitz mode

;Mouse On ; Turn on mouse

; Create the main slice (the bitmap width must be a multiple of 16, otherwise the graphics becomes scrambled)
; slice#, ypos, width, height, flags, bitplanes, sprites, colors, bitmap1_width, bitmap2_width
Slice 0,44,320,192,$fff8,4,8,16,352,352

Use Palette 0

; Draw tiles to fill the whole bitmap
For y = 0 to #bm_map_height-1
  For x = 0 to #bm_map_width-1
    ; Map is exported from Tiled, there 0 means no tile, because of that the tile value is reduced by one
    Block mapa(x,y)-1, x LSL 4, y LSL 4
  Next
Next

x_map = 1
y_map = 1
x_slice = 16
y_slice = 16
db = 0

; }

Repeat
 
  VWait
 
  Show db, x_slice, y_slice ; Show the slice
  CopyBitMap db, 1-db
  db = 1-db
  Use BitMap db
 
  If Joyx(1) = 1
 
    x_slice + 1
   
    If x_slice MOD 16 = 0
      BlockScroll 32,16,320,192,16,16
      For y = 1 to #bm_map_height-2
        Block mapa(mapposx+#bm_map_width,y)-1, 336, y LSL 4
      Next
      mapposx + 1
      x_slice = 16
    EndIf
   
  End If
 
Until Joyb(1) > 0


Daedalus 17 March 2017 17:23

Hmmm... You're copying the whole bitmap every frame? I don't think you would need to do that - just do the blocks that need to be redrawn on each bitmap as needed and swap it out. Copy the bitmap at the start before you enter the main loop and you should be fine. Other than that it looks ok to me, but I haven't tested it...

Retro1234 17 March 2017 17:58

Next Question What does Blockscroll do?

Full hardware scrolling was done like this http://eab.abime.net/showthread.php?t=80646 or/and http://eab.abime.net/showthread.php?t=81634 or a large screen but this is a whole other thread :)

You can use DisplayBitMap to scroll the screen.

MickGyver 17 March 2017 18:07

Ok thanks, so I need to handle the scrolling for both bitmaps separately somehow since they get "out of sync" every frame if scrolling.

MickGyver 17 March 2017 18:14

Quote:

Originally Posted by Retro1234 (Post 1147464)
What does blockscroll do?

Full hardware scrolling was done like this http://eab.abime.net/showthread.php?t=80646 or/and http://eab.abime.net/showthread.php?t=81634 or a large screen but this is a whole other thread :)

You can use DisplayBitMap to scroll the screen.

BlockScroll moves or copies a part of a bitmap: http://amiga.sourceforge.net/amigade...&action=Search

I have been looking at the full hardware scrolling and have managed to do horisontal scrolling in both directions using corkscew with a 100 screen wide tilemap. First I did it with DisplayBitMap and copperlists but there seems to be a bug in DisplayBitMap, setting an x-value over 8191 ($1fff) will offset and garble the screen (so max 26 screens possible). When I switched to using slices it worked for at least 100 screens, didn't try anything bigger.

Doing 8way hardware scrolling is more complicated though.


All times are GMT +2. The time now is 19:47.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.

Page generated in 0.07413 seconds with 11 queries