Aktuelle Zeit: 05.06.2020 17:13

Alle Zeiten sind UTC + 1 Stunde [ Sommerzeit ]




Ein neues Thema erstellen Auf das Thema antworten  [ 8 Beiträge ] 
Autor Nachricht
 Betreff des Beitrags: [LIB] Chip8 Renderer [Windows x64]
BeitragVerfasst: 04.03.2020 16:22 
Offline
Benutzeravatar

Registriert: 25.09.2016 01:42
Ein kleine sehr einfache (in fasm geschriebene) Render Library für ein Chip8 Projekt oder andere kleine Spiele.

Features:
- automatische Anpassung der Renderausgabe an die Fenster- / Gadgetgröße (Seitenverhältnis wird berücksichtigt)
- eigene Farben (oder ganze Farbpaletten) für den Hinter- und Vordergrund / oder direkte per Pixel Farben
- Zeitgeber (16 ms Takt) für das Rendern bzw. als Timer für den Chip8 (CPU freundlich)
- Pixel Zeichenfunktionen mit und ohne Überprüfung der Eingabeparameter

Die Auflösung ist fix und beträgt gemäß Chip8 Spezifikation: 64 x 32 Pixel!

Beispiel:
Code:
;CHIP8DIB - A SMALL DIB RENDERER FOR A CHIP8 PROJECT
;AUTHOR: MIJIKAI
;VERSION: 1.2

EnableExplicit

Import "chip8dib.lib";v.1.2
  chip8CreateDIB.i(hwnd.i)
EndImport

Interface CHIP8DIB
  Clear.i();clear the backbuffer
  Pixel.i(X.i,Y.i);draws a pixel to the backbuffer using the palette color or single color set
  PixelTest.i(X.i,Y.i);also draws a pixel but checks the boundaries!
  PixelColor.i(X.i,Y.i,Color.i);draws a pixel using the color selected
  PixelColorTest.i(X.i,Y.i,Color.i)
  Blit.i();flips the buffers
  Color.i(Color.i,Type.i = #Null,Flag.i = #Null);color = color value or pointer to palette / if type = 0 -> upload palette; type = 1 -> set color / flag = 0 back- flag = 1 foreground
  Resize.i();autmatically adjust the ouput to the host size - gadget or window!
  Clock.i()
  Release.i();release all resources
EndInterface

Procedure.i Chip8UploadPalette(*chip8dib.CHIP8DIB,Flag.i)
  *chip8dib\Color(?chip8_color,0,Flag)
  ProcedureReturn #Null
  chip8_color:;palette = 64 x 32 colors!
  !dd 0xFF009176,0xFF009377,0xFF009477,0xFF009578,0xFF009778,0xFF009879,0xFF009979,0xFF009B7A,0xFF009C7A,0xFF009D7B,0xFF009E7B,0xFF00A07C,0xFF00A17C,0xFF00A27D,0xFF00A37D,0xFF00A47E,0xFF00A67E,0xFF00A77F,0xFF00A87F,0xFF00A980,0xFF00AA80,0xFF00AB80,0xFF00AC81,0xFF00AC81,0xFF00AD81,0xFF00AE82,0xFF00AE82,0xFF00AF82,0xFF00AF82,0xFF00AF82,0xFF00B082,0xFF00B082,0xFF00B082,0xFF00B082,0xFF00AF82,0xFF00AF82,0xFF00AF82,0xFF00AE82,0xFF00AE82,0xFF00AD81,0xFF00AC81,0xFF00AC81,0xFF00AB80,0xFF00AA80,0xFF00A980,0xFF00A87F,0xFF00A77F,0xFF00A67E,0xFF00A47E,0xFF00A37D,0xFF00A27D,0xFF00A17C,0xFF00A07C,0xFF009E7B,0xFF009D7B,0xFF009C7A,0xFF009B7A,0xFF009979,0xFF009879,0xFF009778,0xFF009578,0xFF009477,0xFF009377,0xFF009176
  !dd 0xFF009276,0xFF009377,0xFF009477,0xFF009678,0xFF009879,0xFF009979,0xFF009A7A,0xFF009B7A,0xFF009D7B,0xFF009E7B,0xFF00A07C,0xFF00A17C,0xFF00A27D,0xFF00A37D,0xFF00A47E,0xFF00A67E,0xFF00A77F,0xFF00A87F,0xFF00A980,0xFF00AA80,0xFF00AB80,0xFF00AC81,0xFF00AD81,0xFF00AE82,0xFF00AE82,0xFF00AF82,0xFF00B082,0xFF00B083,0xFF00B183,0xFF00B183,0xFF00B183,0xFF00B183,0xFF00B183,0xFF00B183,0xFF00B183,0xFF00B183,0xFF00B083,0xFF00B082,0xFF00AF82,0xFF00AE82,0xFF00AE82,0xFF00AD81,0xFF00AC81,0xFF00AB80,0xFF00AA80,0xFF00A980,0xFF00A87F,0xFF00A77F,0xFF00A67E,0xFF00A47E,0xFF00A37D,0xFF00A27D,0xFF00A17C,0xFF00A07C,0xFF009E7B,0xFF009D7B,0xFF009B7A,0xFF009A7A,0xFF009979,0xFF009879,0xFF009678,0xFF009477,0xFF009377,0xFF009276
  !dd 0xFF009277,0xFF009477,0xFF009578,0xFF009778,0xFF009879,0xFF009979,0xFF009B7A,0xFF009C7A,0xFF009E7B,0xFF009F7C,0xFF00A07C,0xFF00A27D,0xFF00A37D,0xFF00A47E,0xFF00A57E,0xFF00A77F,0xFF00A87F,0xFF00A980,0xFF00AA80,0xFF00AB81,0xFF00AC81,0xFF00AD81,0xFF00AE82,0xFF00AF82,0xFF00B082,0xFF00B183,0xFF00B183,0xFF00B283,0xFF00B283,0xFF00B383,0xFF00B384,0xFF00B384,0xFF00B384,0xFF00B384,0xFF00B383,0xFF00B283,0xFF00B283,0xFF00B183,0xFF00B183,0xFF00B082,0xFF00AF82,0xFF00AE82,0xFF00AD81,0xFF00AC81,0xFF00AB81,0xFF00AA80,0xFF00A980,0xFF00A87F,0xFF00A77F,0xFF00A57E,0xFF00A47E,0xFF00A37D,0xFF00A27D,0xFF00A07C,0xFF009F7C,0xFF009E7B,0xFF009C7A,0xFF009B7A,0xFF009979,0xFF009879,0xFF009778,0xFF009578,0xFF009477,0xFF009377
  !dd 0xFF009377,0xFF009477,0xFF009678,0xFF009778,0xFF009979,0xFF009A7A,0xFF009C7A,0xFF009D7B,0xFF009E7B,0xFF00A07C,0xFF00A17C,0xFF00A37D,0xFF00A47D,0xFF00A57E,0xFF00A67F,0xFF00A77F,0xFF00A980,0xFF00AA80,0xFF00AB81,0xFF00AC81,0xFF00AE81,0xFF00AE82,0xFF00AF82,0xFF00B083,0xFF00B183,0xFF00B283,0xFF00B383,0xFF00B384,0xFF00B484,0xFF00B484,0xFF00B484,0xFF00B484,0xFF00B484,0xFF00B484,0xFF00B484,0xFF00B484,0xFF00B384,0xFF00B383,0xFF00B283,0xFF00B183,0xFF00B083,0xFF00AF82,0xFF00AE82,0xFF00AE81,0xFF00AC81,0xFF00AB81,0xFF00AA80,0xFF00A980,0xFF00A77F,0xFF00A67F,0xFF00A57E,0xFF00A47D,0xFF00A37D,0xFF00A17C,0xFF00A07C,0xFF009E7B,0xFF009D7B,0xFF009C7A,0xFF009A7A,0xFF009979,0xFF009778,0xFF009678,0xFF009477,0xFF009377
  !dd 0xFF009477,0xFF009578,0xFF009678,0xFF009879,0xFF009979,0xFF009B7A,0xFF009C7A,0xFF009E7B,0xFF009F7C,0xFF00A17C,0xFF00A27D,0xFF00A37D,0xFF00A47E,0xFF00A67E,0xFF00A77F,0xFF00A97F,0xFF00AA80,0xFF00AB80,0xFF00AC81,0xFF00AE81,0xFF00AF82,0xFF00B082,0xFF00B183,0xFF00B283,0xFF00B383,0xFF00B384,0xFF00B484,0xFF00B584,0xFF00B585,0xFF00B685,0xFF00B685,0xFF00B685,0xFF00B685,0xFF00B685,0xFF00B685,0xFF00B585,0xFF00B584,0xFF00B484,0xFF00B384,0xFF00B383,0xFF00B283,0xFF00B183,0xFF00B082,0xFF00AF82,0xFF00AE81,0xFF00AC81,0xFF00AB80,0xFF00AA80,0xFF00A97F,0xFF00A77F,0xFF00A67E,0xFF00A47E,0xFF00A37D,0xFF00A27D,0xFF00A17C,0xFF009F7C,0xFF009E7B,0xFF009C7A,0xFF009B7A,0xFF009979,0xFF009879,0xFF009678,0xFF009578,0xFF009477
  !dd 0xFF009477,0xFF009678,0xFF009778,0xFF009879,0xFF009A7A,0xFF009B7A,0xFF009D7B,0xFF009E7B,0xFF00A07C,0xFF00A17C,0xFF00A37D,0xFF00A47E,0xFF00A57E,0xFF00A77F,0xFF00A87F,0xFF00A980,0xFF00AB80,0xFF00AC81,0xFF00AD81,0xFF00AE82,0xFF00B082,0xFF00B183,0xFF00B283,0xFF00B384,0xFF00B484,0xFF00B584,0xFF00B685,0xFF00B685,0xFF00B785,0xFF00B785,0xFF00B785,0xFF00B785,0xFF00B785,0xFF00B785,0xFF00B785,0xFF00B785,0xFF00B685,0xFF00B685,0xFF00B584,0xFF00B484,0xFF00B384,0xFF00B283,0xFF00B183,0xFF00B082,0xFF00AE82,0xFF00AD81,0xFF00AC81,0xFF00AB80,0xFF00A980,0xFF00A87F,0xFF00A77F,0xFF00A57E,0xFF00A47E,0xFF00A37D,0xFF00A17C,0xFF00A07C,0xFF009E7B,0xFF009D7B,0xFF009B7A,0xFF009A7A,0xFF009979,0xFF009778,0xFF009678,0xFF009477
  !dd 0xFF009477,0xFF009678,0xFF009879,0xFF009979,0xFF009B7A,0xFF009C7A,0xFF009D7B,0xFF009F7C,0xFF00A07C,0xFF00A27D,0xFF00A37D,0xFF00A57E,0xFF00A67E,0xFF00A77F,0xFF00A980,0xFF00AA80,0xFF00AC81,0xFF00AD81,0xFF00AE82,0xFF00AF82,0xFF00B183,0xFF00B283,0xFF00B384,0xFF00B484,0xFF00B584,0xFF00B685,0xFF00B785,0xFF00B785,0xFF00B886,0xFF00B986,0xFF00B986,0xFF00B986,0xFF00B986,0xFF00B986,0xFF00B986,0xFF00B886,0xFF00B785,0xFF00B785,0xFF00B685,0xFF00B584,0xFF00B484,0xFF00B384,0xFF00B283,0xFF00B183,0xFF00AF82,0xFF00AE82,0xFF00AD81,0xFF00AC81,0xFF00AA80,0xFF00A980,0xFF00A77F,0xFF00A67E,0xFF00A57E,0xFF00A37D,0xFF00A27D,0xFF00A07C,0xFF009F7C,0xFF009E7B,0xFF009C7A,0xFF009B7A,0xFF009979,0xFF009879,0xFF009678,0xFF009477
  !dd 0xFF009578,0xFF009678,0xFF009879,0xFF009979,0xFF009B7A,0xFF009C7B,0xFF009E7B,0xFF00A07C,0xFF00A17C,0xFF00A27D,0xFF00A47E,0xFF00A57E,0xFF00A77F,0xFF00A87F,0xFF00A980,0xFF00AB80,0xFF00AC81,0xFF00AE82,0xFF00AF82,0xFF00B083,0xFF00B283,0xFF00B384,0xFF00B484,0xFF00B585,0xFF00B685,0xFF00B785,0xFF00B886,0xFF00B986,0xFF00BA86,0xFF00BA86,0xFF00BB87,0xFF00BB87,0xFF00BB87,0xFF00BB87,0xFF00BA86,0xFF00BA86,0xFF00B986,0xFF00B886,0xFF00B785,0xFF00B685,0xFF00B585,0xFF00B484,0xFF00B384,0xFF00B283,0xFF00B083,0xFF00AF82,0xFF00AE82,0xFF00AC81,0xFF00AB80,0xFF00AA80,0xFF00A87F,0xFF00A77F,0xFF00A57E,0xFF00A47E,0xFF00A27D,0xFF00A17C,0xFF00A07C,0xFF009E7B,0xFF009C7B,0xFF009B7A,0xFF009979,0xFF009879,0xFF009678,0xFF009578
  !dd 0xFF009578,0xFF009778,0xFF009879,0xFF009A7A,0xFF009B7A,0xFF009D7B,0xFF009E7B,0xFF00A07C,0xFF00A17D,0xFF00A37D,0xFF00A47E,0xFF00A67E,0xFF00A77F,0xFF00A980,0xFF00AA80,0xFF00AC81,0xFF00AD81,0xFF00AE82,0xFF00B082,0xFF00B183,0xFF00B383,0xFF00B484,0xFF00B584,0xFF00B685,0xFF00B785,0xFF00B986,0xFF00B986,0xFF00BA86,0xFF00BB87,0xFF00BC87,0xFF00BC87,0xFF00BC87,0xFF00BC87,0xFF00BC87,0xFF00BC87,0xFF00BB87,0xFF00BA86,0xFF00B986,0xFF00B986,0xFF00B785,0xFF00B685,0xFF00B584,0xFF00B484,0xFF00B383,0xFF00B183,0xFF00B082,0xFF00AE82,0xFF00AD81,0xFF00AC81,0xFF00AA80,0xFF00A980,0xFF00A77F,0xFF00A67E,0xFF00A47E,0xFF00A37D,0xFF00A17D,0xFF00A07C,0xFF009E7B,0xFF009D7B,0xFF009B7A,0xFF009A7A,0xFF009879,0xFF009778,0xFF009578
  !dd 0xFF009678,0xFF009778,0xFF009979,0xFF009A7A,0xFF009C7A,0xFF009D7B,0xFF009F7C,0xFF00A07C,0xFF00A27D,0xFF00A37D,0xFF00A57E,0xFF00A67F,0xFF00A87F,0xFF00A980,0xFF00AB80,0xFF00AC81,0xFF00AE82,0xFF00AF82,0xFF00B183,0xFF00B283,0xFF00B384,0xFF00B584,0xFF00B685,0xFF00B785,0xFF00B986,0xFF00BA86,0xFF00BB87,0xFF00BC87,0xFF00BC87,0xFF00BD88,0xFF00BE88,0xFF00BE88,0xFF00BE88,0xFF00BE88,0xFF00BD88,0xFF00BC87,0xFF00BC87,0xFF00BB87,0xFF00BA86,0xFF00B986,0xFF00B785,0xFF00B685,0xFF00B584,0xFF00B384,0xFF00B283,0xFF00B183,0xFF00AF82,0xFF00AE82,0xFF00AC81,0xFF00AB80,0xFF00A980,0xFF00A87F,0xFF00A67F,0xFF00A57E,0xFF00A37D,0xFF00A27D,0xFF00A07C,0xFF009F7C,0xFF009D7B,0xFF009C7A,0xFF009A7A,0xFF009979,0xFF009778,0xFF009678
  !dd 0xFF009678,0xFF009879,0xFF009979,0xFF009B7A,0xFF009C7A,0xFF009E7B,0xFF009F7C,0xFF00A17C,0xFF00A27D,0xFF00A47D,0xFF00A57E,0xFF00A77F,0xFF00A87F,0xFF00AA80,0xFF00AB81,0xFF00AD81,0xFF00AE82,0xFF00B082,0xFF00B183,0xFF00B383,0xFF00B484,0xFF00B685,0xFF00B785,0xFF00B886,0xFF00B986,0xFF00BB87,0xFF00BC87,0xFF00BD88,0xFF00BE88,0xFF00BF88,0xFF00BF88,0xFF00BF89,0xFF00BF89,0xFF00BF88,0xFF00BF88,0xFF00BE88,0xFF00BD88,0xFF00BC87,0xFF00BB87,0xFF00B986,0xFF00B886,0xFF00B785,0xFF00B685,0xFF00B484,0xFF00B384,0xFF00B183,0xFF00B082,0xFF00AE82,0xFF00AD81,0xFF00AB81,0xFF00AA80,0xFF00A87F,0xFF00A77F,0xFF00A57E,0xFF00A47D,0xFF00A27D,0xFF00A17C,0xFF009F7C,0xFF009E7B,0xFF009C7A,0xFF009B7A,0xFF009979,0xFF009879,0xFF009678
  !dd 0xFF009678,0xFF009879,0xFF009979,0xFF009B7A,0xFF009C7B,0xFF009E7B,0xFF00A07C,0xFF00A17C,0xFF00A37D,0xFF00A47E,0xFF00A67E,0xFF00A77F,0xFF00A97F,0xFF00AA80,0xFF00AC81,0xFF00AD81,0xFF00AF82,0xFF00B083,0xFF00B283,0xFF00B384,0xFF00B584,0xFF00B685,0xFF00B785,0xFF00B986,0xFF00BA86,0xFF00BC87,0xFF00BD88,0xFF00BE88,0xFF00BF88,0xFF00C089,0xFF00C189,0xFF00C189,0xFF00C189,0xFF00C189,0xFF00C089,0xFF00BF88,0xFF00BE88,0xFF00BD88,0xFF00BC87,0xFF00BA86,0xFF00B986,0xFF00B785,0xFF00B685,0xFF00B584,0xFF00B384,0xFF00B283,0xFF00B083,0xFF00AF82,0xFF00AD81,0xFF00AC81,0xFF00AA80,0xFF00A97F,0xFF00A77F,0xFF00A67E,0xFF00A47E,0xFF00A37D,0xFF00A17C,0xFF00A07C,0xFF009E7B,0xFF009C7B,0xFF009B7A,0xFF009979,0xFF009879,0xFF009678
  !dd 0xFF009678,0xFF009879,0xFF009979,0xFF009B7A,0xFF009D7B,0xFF009E7B,0xFF00A07C,0xFF00A17C,0xFF00A37D,0xFF00A47E,0xFF00A67E,0xFF00A77F,0xFF00A980,0xFF00AB80,0xFF00AC81,0xFF00AE81,0xFF00AF82,0xFF00B183,0xFF00B283,0xFF00B484,0xFF00B585,0xFF00B785,0xFF00B886,0xFF00BA86,0xFF00BB87,0xFF00BC87,0xFF00BE88,0xFF00BF88,0xFF00C089,0xFF00C189,0xFF00C28A,0xFF00C28A,0xFF00C28A,0xFF00C28A,0xFF00C189,0xFF00C089,0xFF00BF88,0xFF00BE88,0xFF00BC87,0xFF00BB87,0xFF00BA86,0xFF00B886,0xFF00B785,0xFF00B585,0xFF00B484,0xFF00B283,0xFF00B183,0xFF00AF82,0xFF00AE81,0xFF00AC81,0xFF00AB80,0xFF00A980,0xFF00A77F,0xFF00A67E,0xFF00A47E,0xFF00A37D,0xFF00A17C,0xFF00A07C,0xFF009E7B,0xFF009D7B,0xFF009B7A,0xFF009979,0xFF009879,0xFF009678
  !dd 0xFF009778,0xFF009879,0xFF009A79,0xFF009B7A,0xFF009D7B,0xFF009E7B,0xFF00A07C,0xFF00A17D,0xFF00A37D,0xFF00A57E,0xFF00A67E,0xFF00A87F,0xFF00A980,0xFF00AB80,0xFF00AC81,0xFF00AE82,0xFF00AF82,0xFF00B183,0xFF00B383,0xFF00B484,0xFF00B685,0xFF00B785,0xFF00B986,0xFF00BA86,0xFF00BC87,0xFF00BD88,0xFF00BF88,0xFF00C089,0xFF00C189,0xFF00C28A,0xFF00C38A,0xFF00C48A,0xFF00C48A,0xFF00C38A,0xFF00C28A,0xFF00C189,0xFF00C089,0xFF00BF88,0xFF00BD88,0xFF00BC87,0xFF00BA86,0xFF00B986,0xFF00B785,0xFF00B685,0xFF00B484,0xFF00B383,0xFF00B183,0xFF00AF82,0xFF00AE82,0xFF00AC81,0xFF00AB80,0xFF00A980,0xFF00A87F,0xFF00A67E,0xFF00A57E,0xFF00A37D,0xFF00A17D,0xFF00A07C,0xFF009E7B,0xFF009D7B,0xFF009B7A,0xFF009A79,0xFF009879,0xFF009778
  !dd 0xFF009778,0xFF009879,0xFF009A79,0xFF009B7A,0xFF009D7B,0xFF009E7B,0xFF00A07C,0xFF00A27D,0xFF00A37D,0xFF00A57E,0xFF00A67F,0xFF00A87F,0xFF00A980,0xFF00AB80,0xFF00AC81,0xFF00AE82,0xFF00B082,0xFF00B183,0xFF00B384,0xFF00B484,0xFF00B685,0xFF00B785,0xFF00B986,0xFF00BB87,0xFF00BC87,0xFF00BE88,0xFF00BF88,0xFF00C189,0xFF00C28A,0xFF00C38A,0xFF00C58B,0xFF00C68B,0xFF00C68B,0xFF00C58B,0xFF00C38A,0xFF00C28A,0xFF00C189,0xFF00BF88,0xFF00BE88,0xFF00BC87,0xFF00BB87,0xFF00B986,0xFF00B785,0xFF00B685,0xFF00B484,0xFF00B384,0xFF00B183,0xFF00B082,0xFF00AE82,0xFF00AC81,0xFF00AB80,0xFF00A980,0xFF00A87F,0xFF00A67F,0xFF00A57E,0xFF00A37D,0xFF00A27D,0xFF00A07C,0xFF009E7B,0xFF009D7B,0xFF009B7A,0xFF009A79,0xFF009879,0xFF009778
  !dd 0xFF009778,0xFF009879,0xFF009A7A,0xFF009B7A,0xFF009D7B,0xFF009F7B,0xFF00A07C,0xFF00A27D,0xFF00A37D,0xFF00A57E,0xFF00A67F,0xFF00A87F,0xFF00A980,0xFF00AB80,0xFF00AD81,0xFF00AE82,0xFF00B082,0xFF00B183,0xFF00B384,0xFF00B484,0xFF00B685,0xFF00B785,0xFF00B986,0xFF00BB87,0xFF00BC87,0xFF00BE88,0xFF00BF89,0xFF00C189,0xFF00C28A,0xFF00C48A,0xFF00C68B,0xFF00C78C,0xFF00C78C,0xFF00C68B,0xFF00C48A,0xFF00C28A,0xFF00C189,0xFF00BF89,0xFF00BE88,0xFF00BC87,0xFF00BB87,0xFF00B986,0xFF00B785,0xFF00B685,0xFF00B484,0xFF00B384,0xFF00B183,0xFF00B082,0xFF00AE82,0xFF00AD81,0xFF00AB80,0xFF00A980,0xFF00A87F,0xFF00A67F,0xFF00A57E,0xFF00A37D,0xFF00A27D,0xFF00A07C,0xFF009F7B,0xFF009D7B,0xFF009B7A,0xFF009A7A,0xFF009879,0xFF009778
  !dd 0xFF009778,0xFF009879,0xFF009A7A,0xFF009B7A,0xFF009D7B,0xFF009F7B,0xFF00A07C,0xFF00A27D,0xFF00A37D,0xFF00A57E,0xFF00A67F,0xFF00A87F,0xFF00A980,0xFF00AB80,0xFF00AD81,0xFF00AE82,0xFF00B082,0xFF00B183,0xFF00B384,0xFF00B484,0xFF00B685,0xFF00B785,0xFF00B986,0xFF00BB87,0xFF00BC87,0xFF00BE88,0xFF00BF89,0xFF00C189,0xFF00C28A,0xFF00C48A,0xFF00C68B,0xFF00C78C,0xFF00C78C,0xFF00C68B,0xFF00C48A,0xFF00C28A,0xFF00C189,0xFF00BF89,0xFF00BE88,0xFF00BC87,0xFF00BB87,0xFF00B986,0xFF00B785,0xFF00B685,0xFF00B484,0xFF00B384,0xFF00B183,0xFF00B082,0xFF00AE82,0xFF00AD81,0xFF00AB80,0xFF00A980,0xFF00A87F,0xFF00A67F,0xFF00A57E,0xFF00A37D,0xFF00A27D,0xFF00A07C,0xFF009F7B,0xFF009D7B,0xFF009B7A,0xFF009A7A,0xFF009879,0xFF009778
  !dd 0xFF009778,0xFF009879,0xFF009A79,0xFF009B7A,0xFF009D7B,0xFF009E7B,0xFF00A07C,0xFF00A27D,0xFF00A37D,0xFF00A57E,0xFF00A67F,0xFF00A87F,0xFF00A980,0xFF00AB80,0xFF00AC81,0xFF00AE82,0xFF00B082,0xFF00B183,0xFF00B384,0xFF00B484,0xFF00B685,0xFF00B785,0xFF00B986,0xFF00BB87,0xFF00BC87,0xFF00BE88,0xFF00BF88,0xFF00C189,0xFF00C28A,0xFF00C38A,0xFF00C58B,0xFF00C68B,0xFF00C68B,0xFF00C58B,0xFF00C38A,0xFF00C28A,0xFF00C189,0xFF00BF88,0xFF00BE88,0xFF00BC87,0xFF00BB87,0xFF00B986,0xFF00B785,0xFF00B685,0xFF00B484,0xFF00B384,0xFF00B183,0xFF00B082,0xFF00AE82,0xFF00AC81,0xFF00AB80,0xFF00A980,0xFF00A87F,0xFF00A67F,0xFF00A57E,0xFF00A37D,0xFF00A27D,0xFF00A07C,0xFF009E7B,0xFF009D7B,0xFF009B7A,0xFF009A79,0xFF009879,0xFF009778
  !dd 0xFF009778,0xFF009879,0xFF009A79,0xFF009B7A,0xFF009D7B,0xFF009E7B,0xFF00A07C,0xFF00A17D,0xFF00A37D,0xFF00A57E,0xFF00A67E,0xFF00A87F,0xFF00A980,0xFF00AB80,0xFF00AC81,0xFF00AE82,0xFF00AF82,0xFF00B183,0xFF00B383,0xFF00B484,0xFF00B685,0xFF00B785,0xFF00B986,0xFF00BA86,0xFF00BC87,0xFF00BD88,0xFF00BF88,0xFF00C089,0xFF00C189,0xFF00C28A,0xFF00C38A,0xFF00C48A,0xFF00C48A,0xFF00C38A,0xFF00C28A,0xFF00C189,0xFF00C089,0xFF00BF88,0xFF00BD88,0xFF00BC87,0xFF00BA86,0xFF00B986,0xFF00B785,0xFF00B685,0xFF00B484,0xFF00B383,0xFF00B183,0xFF00AF82,0xFF00AE82,0xFF00AC81,0xFF00AB80,0xFF00A980,0xFF00A87F,0xFF00A67E,0xFF00A57E,0xFF00A37D,0xFF00A17D,0xFF00A07C,0xFF009E7B,0xFF009D7B,0xFF009B7A,0xFF009A79,0xFF009879,0xFF009778
  !dd 0xFF009678,0xFF009879,0xFF009979,0xFF009B7A,0xFF009D7B,0xFF009E7B,0xFF00A07C,0xFF00A17C,0xFF00A37D,0xFF00A47E,0xFF00A67E,0xFF00A77F,0xFF00A980,0xFF00AB80,0xFF00AC81,0xFF00AE81,0xFF00AF82,0xFF00B183,0xFF00B283,0xFF00B484,0xFF00B585,0xFF00B785,0xFF00B886,0xFF00BA86,0xFF00BB87,0xFF00BC87,0xFF00BE88,0xFF00BF88,0xFF00C089,0xFF00C189,0xFF00C28A,0xFF00C28A,0xFF00C28A,0xFF00C28A,0xFF00C189,0xFF00C089,0xFF00BF88,0xFF00BE88,0xFF00BC87,0xFF00BB87,0xFF00BA86,0xFF00B886,0xFF00B785,0xFF00B585,0xFF00B484,0xFF00B283,0xFF00B183,0xFF00AF82,0xFF00AE81,0xFF00AC81,0xFF00AB80,0xFF00A980,0xFF00A77F,0xFF00A67E,0xFF00A47E,0xFF00A37D,0xFF00A17C,0xFF00A07C,0xFF009E7B,0xFF009D7B,0xFF009B7A,0xFF009979,0xFF009879,0xFF009678
  !dd 0xFF009678,0xFF009879,0xFF009979,0xFF009B7A,0xFF009C7B,0xFF009E7B,0xFF00A07C,0xFF00A17C,0xFF00A37D,0xFF00A47E,0xFF00A67E,0xFF00A77F,0xFF00A97F,0xFF00AA80,0xFF00AC81,0xFF00AD81,0xFF00AF82,0xFF00B083,0xFF00B283,0xFF00B384,0xFF00B584,0xFF00B685,0xFF00B785,0xFF00B986,0xFF00BA86,0xFF00BC87,0xFF00BD88,0xFF00BE88,0xFF00BF88,0xFF00C089,0xFF00C189,0xFF00C189,0xFF00C189,0xFF00C189,0xFF00C089,0xFF00BF88,0xFF00BE88,0xFF00BD88,0xFF00BC87,0xFF00BA86,0xFF00B986,0xFF00B785,0xFF00B685,0xFF00B584,0xFF00B384,0xFF00B283,0xFF00B083,0xFF00AF82,0xFF00AD81,0xFF00AC81,0xFF00AA80,0xFF00A97F,0xFF00A77F,0xFF00A67E,0xFF00A47E,0xFF00A37D,0xFF00A17C,0xFF00A07C,0xFF009E7B,0xFF009C7B,0xFF009B7A,0xFF009979,0xFF009879,0xFF009678
  !dd 0xFF009678,0xFF009879,0xFF009979,0xFF009B7A,0xFF009C7A,0xFF009E7B,0xFF009F7C,0xFF00A17C,0xFF00A27D,0xFF00A47D,0xFF00A57E,0xFF00A77F,0xFF00A87F,0xFF00AA80,0xFF00AB81,0xFF00AD81,0xFF00AE82,0xFF00B082,0xFF00B183,0xFF00B383,0xFF00B484,0xFF00B685,0xFF00B785,0xFF00B886,0xFF00B986,0xFF00BB87,0xFF00BC87,0xFF00BD88,0xFF00BE88,0xFF00BF88,0xFF00BF88,0xFF00BF89,0xFF00BF89,0xFF00BF88,0xFF00BF88,0xFF00BE88,0xFF00BD88,0xFF00BC87,0xFF00BB87,0xFF00B986,0xFF00B886,0xFF00B785,0xFF00B685,0xFF00B484,0xFF00B384,0xFF00B183,0xFF00B082,0xFF00AE82,0xFF00AD81,0xFF00AB81,0xFF00AA80,0xFF00A87F,0xFF00A77F,0xFF00A57E,0xFF00A47E,0xFF00A27D,0xFF00A17C,0xFF009F7C,0xFF009E7B,0xFF009C7A,0xFF009B7A,0xFF009979,0xFF009879,0xFF009678
  !dd 0xFF009678,0xFF009778,0xFF009979,0xFF009A7A,0xFF009C7A,0xFF009D7B,0xFF009F7C,0xFF00A07C,0xFF00A27D,0xFF00A37D,0xFF00A57E,0xFF00A67F,0xFF00A87F,0xFF00A980,0xFF00AB80,0xFF00AC81,0xFF00AE82,0xFF00AF82,0xFF00B183,0xFF00B283,0xFF00B384,0xFF00B584,0xFF00B685,0xFF00B785,0xFF00B986,0xFF00BA86,0xFF00BB87,0xFF00BC87,0xFF00BC87,0xFF00BD88,0xFF00BE88,0xFF00BE88,0xFF00BE88,0xFF00BE88,0xFF00BD88,0xFF00BC87,0xFF00BC87,0xFF00BB87,0xFF00BA86,0xFF00B986,0xFF00B785,0xFF00B685,0xFF00B584,0xFF00B384,0xFF00B283,0xFF00B183,0xFF00AF82,0xFF00AE82,0xFF00AC81,0xFF00AB80,0xFF00A980,0xFF00A87F,0xFF00A67F,0xFF00A57E,0xFF00A37D,0xFF00A27D,0xFF00A07C,0xFF009F7C,0xFF009D7B,0xFF009C7A,0xFF009A7A,0xFF009979,0xFF009778,0xFF009678
  !dd 0xFF009578,0xFF009778,0xFF009879,0xFF009A7A,0xFF009B7A,0xFF009D7B,0xFF009E7B,0xFF00A07C,0xFF00A17D,0xFF00A37D,0xFF00A47E,0xFF00A67E,0xFF00A77F,0xFF00A980,0xFF00AA80,0xFF00AC81,0xFF00AD81,0xFF00AE82,0xFF00B082,0xFF00B183,0xFF00B383,0xFF00B484,0xFF00B584,0xFF00B685,0xFF00B785,0xFF00B986,0xFF00B986,0xFF00BA86,0xFF00BB87,0xFF00BC87,0xFF00BC87,0xFF00BC87,0xFF00BC87,0xFF00BC87,0xFF00BC87,0xFF00BB87,0xFF00BA86,0xFF00B986,0xFF00B986,0xFF00B785,0xFF00B685,0xFF00B584,0xFF00B484,0xFF00B383,0xFF00B183,0xFF00B082,0xFF00AE82,0xFF00AD81,0xFF00AC81,0xFF00AA80,0xFF00A980,0xFF00A77F,0xFF00A67E,0xFF00A47E,0xFF00A37D,0xFF00A17D,0xFF00A07C,0xFF009E7B,0xFF009D7B,0xFF009B7A,0xFF009A7A,0xFF009879,0xFF009778,0xFF009578
  !dd 0xFF009578,0xFF009678,0xFF009879,0xFF009979,0xFF009B7A,0xFF009C7B,0xFF009E7B,0xFF00A07C,0xFF00A17C,0xFF00A27D,0xFF00A47E,0xFF00A57E,0xFF00A77F,0xFF00A87F,0xFF00AA80,0xFF00AB80,0xFF00AC81,0xFF00AE82,0xFF00AF82,0xFF00B083,0xFF00B283,0xFF00B384,0xFF00B484,0xFF00B585,0xFF00B685,0xFF00B785,0xFF00B886,0xFF00B986,0xFF00BA86,0xFF00BA86,0xFF00BB87,0xFF00BB87,0xFF00BB87,0xFF00BB87,0xFF00BA86,0xFF00BA86,0xFF00B986,0xFF00B886,0xFF00B785,0xFF00B685,0xFF00B585,0xFF00B484,0xFF00B384,0xFF00B283,0xFF00B083,0xFF00AF82,0xFF00AE82,0xFF00AC81,0xFF00AB80,0xFF00AA80,0xFF00A87F,0xFF00A77F,0xFF00A57E,0xFF00A47E,0xFF00A37D,0xFF00A17C,0xFF00A07C,0xFF009E7B,0xFF009C7B,0xFF009B7A,0xFF009979,0xFF009879,0xFF009678,0xFF009578
  !dd 0xFF009477,0xFF009678,0xFF009879,0xFF009979,0xFF009B7A,0xFF009C7A,0xFF009D7B,0xFF009F7C,0xFF00A07C,0xFF00A27D,0xFF00A37D,0xFF00A57E,0xFF00A67E,0xFF00A77F,0xFF00A980,0xFF00AA80,0xFF00AC81,0xFF00AD81,0xFF00AE82,0xFF00AF82,0xFF00B183,0xFF00B283,0xFF00B384,0xFF00B484,0xFF00B584,0xFF00B685,0xFF00B785,0xFF00B785,0xFF00B886,0xFF00B986,0xFF00B986,0xFF00B986,0xFF00B986,0xFF00B986,0xFF00B986,0xFF00B886,0xFF00B785,0xFF00B785,0xFF00B685,0xFF00B584,0xFF00B484,0xFF00B384,0xFF00B283,0xFF00B183,0xFF00AF82,0xFF00AE82,0xFF00AD81,0xFF00AC81,0xFF00AA80,0xFF00A980,0xFF00A77F,0xFF00A67E,0xFF00A57E,0xFF00A37D,0xFF00A27D,0xFF00A07C,0xFF009F7C,0xFF009E7B,0xFF009C7A,0xFF009B7A,0xFF009979,0xFF009879,0xFF009678,0xFF009477
  !dd 0xFF009477,0xFF009678,0xFF009778,0xFF009979,0xFF009A7A,0xFF009B7A,0xFF009D7B,0xFF009E7B,0xFF00A07C,0xFF00A17C,0xFF00A37D,0xFF00A47E,0xFF00A57E,0xFF00A77F,0xFF00A87F,0xFF00A980,0xFF00AB80,0xFF00AC81,0xFF00AD81,0xFF00AE82,0xFF00B082,0xFF00B183,0xFF00B283,0xFF00B384,0xFF00B484,0xFF00B584,0xFF00B685,0xFF00B685,0xFF00B785,0xFF00B785,0xFF00B785,0xFF00B785,0xFF00B785,0xFF00B785,0xFF00B785,0xFF00B785,0xFF00B685,0xFF00B685,0xFF00B584,0xFF00B484,0xFF00B384,0xFF00B283,0xFF00B183,0xFF00B082,0xFF00AE82,0xFF00AD81,0xFF00AC81,0xFF00AB80,0xFF00A980,0xFF00A87F,0xFF00A77F,0xFF00A57E,0xFF00A47E,0xFF00A37D,0xFF00A17C,0xFF00A07C,0xFF009E7B,0xFF009D7B,0xFF009B7A,0xFF009A7A,0xFF009979,0xFF009778,0xFF009678,0xFF009477
  !dd 0xFF009477,0xFF009578,0xFF009678,0xFF009879,0xFF009979,0xFF009B7A,0xFF009C7A,0xFF009E7B,0xFF009F7C,0xFF00A17C,0xFF00A27D,0xFF00A37D,0xFF00A47E,0xFF00A67E,0xFF00A77F,0xFF00A97F,0xFF00AA80,0xFF00AB80,0xFF00AC81,0xFF00AE81,0xFF00AF82,0xFF00B082,0xFF00B183,0xFF00B283,0xFF00B383,0xFF00B384,0xFF00B484,0xFF00B584,0xFF00B585,0xFF00B685,0xFF00B685,0xFF00B685,0xFF00B685,0xFF00B685,0xFF00B685,0xFF00B585,0xFF00B584,0xFF00B484,0xFF00B384,0xFF00B383,0xFF00B283,0xFF00B183,0xFF00B082,0xFF00AF82,0xFF00AE81,0xFF00AC81,0xFF00AB80,0xFF00AA80,0xFF00A97F,0xFF00A77F,0xFF00A67E,0xFF00A47E,0xFF00A37D,0xFF00A27D,0xFF00A17C,0xFF009F7C,0xFF009E7B,0xFF009C7A,0xFF009B7A,0xFF009979,0xFF009879,0xFF009678,0xFF009578,0xFF009477
  !dd 0xFF009377,0xFF009477,0xFF009678,0xFF009778,0xFF009979,0xFF009A7A,0xFF009C7A,0xFF009D7B,0xFF009E7B,0xFF00A07C,0xFF00A17C,0xFF00A37D,0xFF00A47E,0xFF00A57E,0xFF00A67F,0xFF00A77F,0xFF00A980,0xFF00AA80,0xFF00AB81,0xFF00AC81,0xFF00AE81,0xFF00AE82,0xFF00AF82,0xFF00B083,0xFF00B183,0xFF00B283,0xFF00B384,0xFF00B384,0xFF00B484,0xFF00B484,0xFF00B484,0xFF00B484,0xFF00B484,0xFF00B484,0xFF00B484,0xFF00B484,0xFF00B384,0xFF00B384,0xFF00B283,0xFF00B183,0xFF00B083,0xFF00AF82,0xFF00AE82,0xFF00AE81,0xFF00AC81,0xFF00AB81,0xFF00AA80,0xFF00A980,0xFF00A77F,0xFF00A67F,0xFF00A57E,0xFF00A47E,0xFF00A37D,0xFF00A17C,0xFF00A07C,0xFF009E7B,0xFF009D7B,0xFF009C7A,0xFF009A7A,0xFF009979,0xFF009879,0xFF009678,0xFF009477,0xFF009377
  !dd 0xFF009377,0xFF009477,0xFF009578,0xFF009778,0xFF009879,0xFF009979,0xFF009B7A,0xFF009C7A,0xFF009E7B,0xFF009F7C,0xFF00A07C,0xFF00A27D,0xFF00A37D,0xFF00A47E,0xFF00A67E,0xFF00A77F,0xFF00A87F,0xFF00A980,0xFF00AA80,0xFF00AB81,0xFF00AC81,0xFF00AD81,0xFF00AE82,0xFF00AF82,0xFF00B082,0xFF00B183,0xFF00B183,0xFF00B283,0xFF00B283,0xFF00B383,0xFF00B384,0xFF00B384,0xFF00B384,0xFF00B384,0xFF00B383,0xFF00B283,0xFF00B283,0xFF00B183,0xFF00B183,0xFF00B082,0xFF00AF82,0xFF00AE82,0xFF00AD81,0xFF00AC81,0xFF00AB81,0xFF00AA80,0xFF00A980,0xFF00A87F,0xFF00A77F,0xFF00A67E,0xFF00A47E,0xFF00A37D,0xFF00A27D,0xFF00A07C,0xFF009F7C,0xFF009E7B,0xFF009C7A,0xFF009B7A,0xFF009979,0xFF009879,0xFF009778,0xFF009578,0xFF009477,0xFF009377
  !dd 0xFF009276,0xFF009377,0xFF009477,0xFF009678,0xFF009879,0xFF009979,0xFF009A7A,0xFF009B7A,0xFF009D7B,0xFF009E7B,0xFF00A07C,0xFF00A17C,0xFF00A27D,0xFF00A37D,0xFF00A47E,0xFF00A67E,0xFF00A77F,0xFF00A87F,0xFF00A980,0xFF00AA80,0xFF00AB80,0xFF00AC81,0xFF00AD81,0xFF00AE82,0xFF00AE82,0xFF00AF82,0xFF00B082,0xFF00B083,0xFF00B183,0xFF00B183,0xFF00B183,0xFF00B183,0xFF00B183,0xFF00B183,0xFF00B183,0xFF00B183,0xFF00B083,0xFF00B082,0xFF00AF82,0xFF00AE82,0xFF00AE82,0xFF00AD81,0xFF00AC81,0xFF00AB80,0xFF00AA80,0xFF00A980,0xFF00A87F,0xFF00A77F,0xFF00A67E,0xFF00A47E,0xFF00A37D,0xFF00A27D,0xFF00A17C,0xFF00A07C,0xFF009E7B,0xFF009D7B,0xFF009B7A,0xFF009A7A,0xFF009979,0xFF009879,0xFF009678,0xFF009477,0xFF009377,0xFF009276
  !dd 0xFF009176,0xFF009377,0xFF009477,0xFF009578,0xFF009778,0xFF009879,0xFF009979,0xFF009B7A,0xFF009C7A,0xFF009D7B,0xFF009F7B,0xFF00A07C,0xFF00A17C,0xFF00A27D,0xFF00A37D,0xFF00A47E,0xFF00A67E,0xFF00A77F,0xFF00A87F,0xFF00A980,0xFF00AA80,0xFF00AB80,0xFF00AC81,0xFF00AC81,0xFF00AD81,0xFF00AE82,0xFF00AE82,0xFF00AF82,0xFF00AF82,0xFF00AF82,0xFF00B082,0xFF00B082,0xFF00B082,0xFF00B082,0xFF00AF82,0xFF00AF82,0xFF00AF82,0xFF00AE82,0xFF00AE82,0xFF00AD81,0xFF00AC81,0xFF00AC81,0xFF00AB80,0xFF00AA80,0xFF00A980,0xFF00A87F,0xFF00A77F,0xFF00A67E,0xFF00A47E,0xFF00A37D,0xFF00A27D,0xFF00A17C,0xFF00A07C,0xFF009F7B,0xFF009D7B,0xFF009C7A,0xFF009B7A,0xFF009979,0xFF009879,0xFF009778,0xFF009578,0xFF009477,0xFF009377,0xFF009176
EndProcedure

Procedure.i Chip8RenderSprite(*chip8dib.CHIP8DIB,*Sprite.Ascii,X.i,Y.i,Width.i,Height.i)
  Protected px.i
  Protected py.i
  Protected pw.i
  Protected ph.i
  pw = (X + Width) - 1
  ph = (Y + Height) - 1
  For py = Y To ph
    For px = X To pw
      If *Sprite\a
        *chip8dib\PixelTest(px,py)
      EndIf
      *Sprite + 1
    Next
  Next
  ProcedureReturn #Null
EndProcedure

Procedure.i Chip8(Title.s = #Null$,Width.i = 800,Height.i = 400)
  Protected wnd.i
  Protected wnd_flags.i
  Protected wnd_event.i
  Protected wnd_exit.i
  Protected timer_start.i
  Protected timer_stop.i
  Protected *chip8dib.CHIP8DIB
  Protected mov.f
 
  wnd_flags = #PB_Window_SystemMenu|#PB_Window_ScreenCentered|#PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget|#PB_Window_SizeGadget
  wnd = OpenWindow(#PB_Any,#Null,#Null,Width,Height,Title,wnd_flags)
  If wnd
    WindowBounds(wnd,Width,Height,#PB_Ignore,#PB_Ignore)
    SetWindowColor(wnd,0)
    *chip8dib = chip8CreateDIB(WindowID(wnd))
    If *chip8dib
      ;*chip8dib\Color($000000,1,0)
      ;*chip8dib\Color($FFFFFF,1,1)
      ;Chip8UploadPalette(*chip8dib,0)
      Repeat
        Repeat
          wnd_event = WindowEvent()
          Select wnd_event
            Case #PB_Event_SizeWindow
              *chip8dib\Resize();auto adjust size + keep aspect ratio
            Case  #PB_Event_CloseWindow
              wnd_exit = #True
          EndSelect
        Until wnd_event = #Null
        *chip8dib\Clear()
        mov + 0.25
        If mov > 70
          mov = 0
        EndIf
        Chip8RenderSprite(*chip8dib,?sprite0,Cos(mov) + mov - 8,Sin(mov + 5) + 20,5,5)
        Chip8RenderSprite(*chip8dib,?sprite1,Cos(mov) + mov,Sin(mov) + 20,5,5)
        Chip8RenderSprite(*chip8dib,?sprite2,48 - (Cos(mov) + mov),4,25,10)
        *chip8dib\Blit()
        *chip8dib\Clock()
      Until wnd_exit
      *chip8dib\Release()
    EndIf
    CloseWindow(wnd)
  EndIf
  ProcedureReturn #Null
EndProcedure

Chip8()

End

DataSection
  sprite0:
  !db 1,1,1,1,0
  !db 1,0,0,0,1
  !db 1,1,1,1,0
  !db 1,0,0,0,0
  !db 1,0,0,0,0
  sprite1:
  !db 1,1,1,1,0
  !db 1,0,0,0,1
  !db 1,1,1,1,0
  !db 1,0,0,0,1
  !db 1,1,1,1,0
  sprite2:
  !db 0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,0,0,1,1,1,1,0,0
  !db 1,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,1,0,1,0,0,0,0,1,0
  !db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,0
  !db 0,1,1,1,1,0,1,0,0,1,0,1,0,1,1,1,1,0,1,0,0,0,0,1,0
  !db 0,1,0,0,0,0,1,1,1,1,0,1,0,1,0,0,1,0,0,1,1,1,1,0,0
  !db 0,1,0,0,0,0,1,0,0,1,0,1,0,1,1,1,1,0,1,0,0,0,0,1,0
  !db 0,1,1,1,1,0,1,0,0,1,0,1,0,1,0,0,0,0,1,0,0,0,0,1,0
  !db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,0
  !db 1,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,1,0,1,0,0,0,0,1,0
  !db 0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,0,0,1,1,1,1,0,0
EndDataSection


Download (chip8dib.lib Version 1.2):
https://www.dropbox.com/s/8u0lwtnv6dvdrq3/chip8dib_v1.2.zip?dl=0

Viel Spass beim Experimentieren :)

_________________

Links:
PureBasic Discord
[ENGINE] 2D Engine Nautilus (Win)
[INCLUDE] GLFW 3.3 Library
[MODULE] Bass Library 2.4 (Win)
[LIBRARY] Hexi Binary2Hex (Win)



Zuletzt geändert von Mijikai am 06.03.2020 21:10, insgesamt 4-mal geändert.

Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags: Re: [LIB] Chip8 Renderer [Windows x64]
BeitragVerfasst: 05.03.2020 15:22 
Offline
Benutzeravatar

Registriert: 25.09.2016 01:42
Update v.1.3 (Windows x64 only!):
- eigener Farbspeicher für jedes Interface (vorher gab es nur einen Globalen Speicher)
- neue Funktion ColorReset() / alle Farbänderungen werden zurückgesetzt

So sieht das neue Interface aus:
Code:
Interface CHIP8DIB
  Clear.i();clear the backbuffer
  Pixel.i(X.i,Y.i);draws a pixel to the backbuffer using the palette color or single color set
  PixelTest.i(X.i,Y.i);also draws a pixel but checks the boundaries!
  PixelColor.i(X.i,Y.i,Color.i);draws a pixel using the color selected
  PixelColorTest.i(X.i,Y.i,Color.i)
  Blit.i();flips the buffers
  Color.i(Color.i,Type.i = #Null,Flag.i = #Null);color = color value or pointer to palette / if type = 0 -> upload palette if type = 1 -> set color / flag = 0 back- flag = 1 foreground
  ColorReset.i()
  Resize.i();autmatically adjust the ouput to the host size - gadget or window!
  Clock.i()
  Release.i();release all resources
EndInterface


Download:
https://www.dropbox.com/s/5lx41yz04fhnsvx/chip8dib_v.1.3.zip?dl=0

_________________

Links:
PureBasic Discord
[ENGINE] 2D Engine Nautilus (Win)
[INCLUDE] GLFW 3.3 Library
[MODULE] Bass Library 2.4 (Win)
[LIBRARY] Hexi Binary2Hex (Win)



Zuletzt geändert von Mijikai am 07.03.2020 12:00, insgesamt 1-mal geändert.

Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags: Re: [LIB] Chip8 Renderer [Windows x64]
BeitragVerfasst: 06.03.2020 21:08 
Offline
Benutzeravatar

Registriert: 25.09.2016 01:42
Update v.1.4 (Windows x64 only!):
- neues Interface & neue Funktionen
- umbenennung der Library!

Was damit machbar ist (Palette-Color Manipulation):
Bild

Neues Interface:
Code:
Import "chip8surface.lib";v.1.4
  chip8CreateSurface.i(hwnd.i)
EndImport

Interface CHIP8_SURFACE
  PixelClear.i()                                    ;clears the screen / fills the backbuffer with palette 0
  Pixel.i(X.i,Y.i)                                  ;draws a pixel at pos xy using the xy color of palette 1
  PixelEx.i(X.i,Y.i)                                ;same as the function above but with boundary checks
  PixelSetColor.i(X.i,Y.i,Color.i)                  ;draws a pixel at pos xy using the provided color
  PixelSetColorEx.i(X.i,Y.i,Color.i)                ;same as the function above but with boundary checks
  PixelGetColor.i(X.i,Y.i)                          ;get the color at pos xy
  PixelGetColorEx.i(X.i,Y.i)                        ;same as the function above but with boundary checks
  PixelBlit.i()                                     ;flips the buffer / render all drawn pixels
  PixelResize.i()                                   ;scales the render surface while keeping the aspect ratio
  PaletteUpdate.i(Index.i,Color.i,Flag.i)           ;upload custom palette (Index 0 / 1) if flag = 0 color is a palette pointer else a fill color!   
  PaletteSetColor.i(Index.i,X.i,Y.i,Color.i)        ;sets a color at pos xy in the selected palette
  PaletteSetColorEx.i(Index.i,X.i,Y.i,Color.i)      ;same as the function above but with boundary checks
  PaletteGetColor.i(Index.i,X.i,Y.i)                ;gets the color stored at pos xy in the selected palette
  PaletteGetColorEx.i(Index.i,X.i,Y.i)              ;same as the function above but with boundary checks
  PaletteReset.i()                                  ;resets palette 0 and 1
  Clock.i()                                         ;a 16 ms timer useful for rendering or emulating the cpu clock of chip8
  Release.i()                                       ;free all resources
EndInterface


Download:
https://www.dropbox.com/s/ye36jej15uab57j/chip8surface_v.1.4.zip?dl=0

Viel Spass :)

_________________

Links:
PureBasic Discord
[ENGINE] 2D Engine Nautilus (Win)
[INCLUDE] GLFW 3.3 Library
[MODULE] Bass Library 2.4 (Win)
[LIBRARY] Hexi Binary2Hex (Win)



Zuletzt geändert von Mijikai am 07.03.2020 12:00, insgesamt 1-mal geändert.

Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags: Re: [LIB] Chip8 Renderer [Windows x64]
BeitragVerfasst: 07.03.2020 00:09 
Offline
Benutzeravatar

Registriert: 10.09.2004 09:59
Du solltest ein Beispiel mitliefern, sonst wird sich das sicherlich niemand anschauen.
Habe mir jetzt einen abgebrochen den Beispielcode oben, für die neue Version umzuschreiben.

Es sollte auch erwähnt werden, dass das nur für 64bit ist.

Eine etwas merkwürdige Präsentation Deiner Arbeit, um es mal freundlich zu formulieren.
Ich dachte eigentlich, das wäre ein cooles Gimmick für Eastereggs, aber scheint doch eher was für Freaks zu sein.

_________________
Link tot?
Ändere h3x0r.ath.cx in hex0rs.coderbu.de und alles wird gut.


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags: Re: [LIB] Chip8 Renderer [Windows x64]
BeitragVerfasst: 07.03.2020 11:56 
Offline
Benutzeravatar

Registriert: 25.09.2016 01:42
HeX0R hat geschrieben:
Du solltest ein Beispiel mitliefern, sonst wird sich das sicherlich niemand anschauen.
Habe mir jetzt einen abgebrochen den Beispielcode oben, für die neue Version umzuschreiben.

Es sollte auch erwähnt werden, dass das nur für 64bit ist.

Eine etwas merkwürdige Präsentation Deiner Arbeit, um es mal freundlich zu formulieren.
Ich dachte eigentlich, das wäre ein cooles Gimmick für Eastereggs, aber scheint doch eher was für Freaks zu sein.


Hallo Hexor :)
danke fürs Feedback.
Für die aktuelle Version gibt es jetzt Beispiele.
Das es nur für Windows x64 ist stand in der Thread Überschrift aber nicht im Update Post werde die Info noch hinzufügen.

Update v.1.5 (Windows x64 only!):
- neue Funktion PixelBlitEx()

Beispiele:
Code:
;CHIP8_SURFACE - A SMALL (DIB) RENDERER
;AUTHOR: MIJIKAI
;VERSION: 1.5
;OS: WINDOWS X64

EnableExplicit

CompilerIf #PB_Compiler_Processor <> #PB_Processor_x64
   CompilerError "Please use the x64 compiler!"
CompilerEndIf

Import "chip8surface.lib";v.1.5
  chip8CreateSurface.i(hwnd.i)
EndImport

Interface CHIP8_SURFACE
  PixelClear.i()                                    ;clears the screen / fills the backbuffer with palette 0
  Pixel.i(X.i,Y.i)                                  ;draws a pixel at pos xy using the xy color of palette 1
  PixelEx.i(X.i,Y.i)                                ;same as the function above but with boundary checks
  PixelSetColor.i(X.i,Y.i,Color.i)                  ;draws a pixel at pos xy using the provided color
  PixelSetColorEx.i(X.i,Y.i,Color.i)                ;same as the function above but with boundary checks
  PixelGetColor.i(X.i,Y.i)                          ;get the color at pos xy
  PixelGetColorEx.i(X.i,Y.i)                        ;same as the function above but with boundary checks
  PixelBlit.i()                                     ;flips the buffer / renders all drawn pixels
  PixelBlitEx.i(X.i,Y.i,Width.i,Height.i)           ;flips the buffer / only renders the set sub section of drawn pixels
  PixelResize.i()                                   ;scales the render surface while keeping the aspect ratio
  PaletteUpdate.i(Index.i,Color.i,Flag.i)           ;upload custom palette (Index 0 / 1) if flag = 0 color is a palette pointer else a fill color!   
  PaletteSetColor.i(Index.i,X.i,Y.i,Color.i)        ;sets a color at pos xy in the selected palette
  PaletteSetColorEx.i(Index.i,X.i,Y.i,Color.i)      ;same as the function above but with boundary checks
  PaletteGetColor.i(Index.i,X.i,Y.i)                ;gets the color stored at pos xy in the selected palette
  PaletteGetColorEx.i(Index.i,X.i,Y.i)              ;same as the function above but with boundary checks
  PaletteReset.i()                                  ;resets palette 0 and 1
  Clock.i()                                         ;a 16 ms timer useful for rendering / or emulating the cpu clock of chip8
  Release.i()                                       ;free all resources
EndInterface

Procedure.i DemoInitialisation(Title.s = #Null$,Width.i = 600,Height.i = 300);initialisation & clearing the backbuffer
  Protected wnd.i
  Protected wnd_flags.i
  Protected wnd_event.i
  Protected wnd_exit.i
  Protected *surface.CHIP8_SURFACE
  wnd_flags = #PB_Window_SystemMenu|#PB_Window_ScreenCentered|#PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget|#PB_Window_SizeGadget
  wnd = OpenWindow(#PB_Any,#Null,#Null,Width,Height,Title,wnd_flags)
  If wnd
    WindowBounds(wnd,Width,Height,#PB_Ignore,#PB_Ignore)
    *surface = chip8CreateSurface(WindowID(wnd));create a render surface
    If *surface
      Repeat
        Repeat
          wnd_event = WindowEvent()
          Select wnd_event
            Case #PB_Event_SizeWindow
              *surface\PixelResize();auto adjust size + keep aspect ratio
            Case #PB_Event_CloseWindow
              wnd_exit = #True
          EndSelect
        Until wnd_event = #Null
        *surface\PixelClear();clears the screen / fills the backbuffer with palette 0
        *surface\PixelBlit() ;flips the buffer / renders all drawn pixels
        *surface\Clock();a 16 ms timer useful for rendering / or emulating the cpu clock of chip8
      Until wnd_exit
      *surface\Release();release all resources
    EndIf
    CloseWindow(wnd)
  EndIf
  ProcedureReturn #Null
EndProcedure

Procedure.i DemoPixel(Title.s = #Null$,Width.i = 600,Height.i = 300);drawing a pixel
  Protected wnd.i
  Protected wnd_flags.i
  Protected wnd_event.i
  Protected wnd_exit.i
  Protected *surface.CHIP8_SURFACE
  wnd_flags = #PB_Window_SystemMenu|#PB_Window_ScreenCentered|#PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget|#PB_Window_SizeGadget
  wnd = OpenWindow(#PB_Any,#Null,#Null,Width,Height,Title,wnd_flags)
  If wnd
    WindowBounds(wnd,Width,Height,#PB_Ignore,#PB_Ignore)
    *surface = chip8CreateSurface(WindowID(wnd))
    If *surface
      Repeat
        Repeat
          wnd_event = WindowEvent()
          Select wnd_event
            Case #PB_Event_SizeWindow
              *surface\PixelResize()
            Case #PB_Event_CloseWindow
              wnd_exit = #True
          EndSelect
        Until wnd_event = #Null
        *surface\PixelClear()
        *surface\Pixel(1,1);draws a pixel at pos xy using the xy color of palette 1
        *surface\PixelEx(4,1);same as the function above but with boundary checks (is the pixel inside the 64 x 32 surface)
        *surface\PixelSetColor(1,4,$FF00FF);draws a pixel at pos xy using the provided color (pink in this example)
        *surface\PixelSetColorEx(4,4,$00FF00);same as the function above but with boundary checks
        Debug "Color @ 1 x 4: " + RSet(Hex(*surface\PixelGetColor(1,4)),6,"0");get the color at pos xy - PixelGetColor does th same but with boundary checks
        *surface\PixelBlit()
        *surface\Clock()
      Until wnd_exit
      *surface\Release()
    EndIf
    CloseWindow(wnd)
  EndIf
  ProcedureReturn #Null
EndProcedure

Procedure.i DemoPalette(Title.s = #Null$,Width.i = 600,Height.i = 300);manipulating the palette!
  Protected wnd.i
  Protected wnd_flags.i
  Protected wnd_event.i
  Protected wnd_exit.i
  Protected *surface.CHIP8_SURFACE
  wnd_flags = #PB_Window_SystemMenu|#PB_Window_ScreenCentered|#PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget|#PB_Window_SizeGadget
  wnd = OpenWindow(#PB_Any,#Null,#Null,Width,Height,Title,wnd_flags)
  If wnd
    WindowBounds(wnd,Width,Height,#PB_Ignore,#PB_Ignore)
    *surface = chip8CreateSurface(WindowID(wnd))
    If *surface
      ;Index parameter:
      ;0 = palette background
      ;1 = palette foreground (pixles)
      ;Color parameter:
      ;if the Flag parameter is 0: Color is a pointer to a color palette with 64 * 32 colors ($2000 bytes)
      ;if the Flag parameter is 1: Color is infact just a color - this will set the whole internal palette to that one color!
      *surface\PaletteUpdate(0,$000000,1);<- lets make the background palette black!
      *surface\PaletteUpdate(1,$FF00FF,1);<- and the foreground palette pink!
      *surface\PaletteSetColor(0,1,1,$00FF00);<- only change one color in the selected palette (the example makes the entry xy green)!
      Debug "Palette Color @ 1x1: " + RSet(Hex(*surface\PaletteGetColor(0,1,1)),6,"0");<- what color is stored at palette position xy
      ;*surface\PaletteReset();<- resets palette 1 & 0
      Repeat
        Repeat
          wnd_event = WindowEvent()
          Select wnd_event
            Case #PB_Event_SizeWindow
              *surface\PixelResize()
            Case #PB_Event_CloseWindow
              wnd_exit = #True
          EndSelect
        Until wnd_event = #Null
        *surface\PixelClear()
        *surface\Pixel(10,10);draw a pixel using the forground palette color!
        *surface\PixelBlit()
        *surface\Clock()
      Until wnd_exit
      *surface\Release()
    EndIf
    CloseWindow(wnd)
  EndIf
  ProcedureReturn #Null
EndProcedure

Procedure.i DemoGadget(Title.s = #Null$,Width.i = 600,Height.i = 300);render into one or more gadget/s!
  Protected wnd.i
  Protected wnd_flags.i
  Protected wnd_event.i
  Protected wnd_exit.i
  Protected *s1.CHIP8_SURFACE
  Protected *s2.CHIP8_SURFACE
  Protected gadget_canvas.i
  Protected gadget_image.i
  wnd_flags = #PB_Window_SystemMenu|#PB_Window_ScreenCentered|#PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget|#PB_Window_SizeGadget
  wnd = OpenWindow(#PB_Any,#Null,#Null,Width,Height,Title,wnd_flags)
  If wnd
    WindowBounds(wnd,Width,Height,#PB_Ignore,#PB_Ignore)
    gadget_canvas = CanvasGadget(#PB_Any,220,10,200,100)
    gadget_image = ImageGadget(#PB_Any,10,10,200,100,#Null)
    If gadget_canvas And gadget_image
      *s1 = chip8CreateSurface(GadgetID(gadget_canvas))
      *s2 = chip8CreateSurface(GadgetID(gadget_image))
      If *s1
        If *s2
          *s1\PaletteUpdate(0,$FF00FF,1)
          *s2\PaletteUpdate(0,$00FF00,1)
          Repeat
            Repeat
              wnd_event = WindowEvent()
              Select wnd_event
                Case #PB_Event_SizeWindow
                  ResizeGadget(gadget_canvas,#PB_Ignore,#PB_Ignore,WindowWidth(wnd) - 380,WindowHeight(wnd) - 190)
                  *s1\PixelResize();only resize the gadget canvas_surface
                Case #PB_Event_CloseWindow
                  wnd_exit = #True
              EndSelect
            Until wnd_event = #Null
            ;--------------
            *s1\PixelClear()
            *s1\PixelBlit()
            ;--------------
            *s2\PixelClear()
            *s2\PixelBlit()
            ;--------------
            *s1\Clock();<- we only need 1 render clock!
          Until wnd_exit
          *s2\Release()
        EndIf
        *s1\Release()
      EndIf
    EndIf
    CloseWindow(wnd)
  EndIf
  ProcedureReturn #Null
EndProcedure

DemoInitialisation("Demo Initialisation")

DemoPixel("Demo Pixel Functions")

DemoPalette("Demo Palette Functions")

DemoGadget("Demo Render into Gadgets")

;PixelBlitEx instead of PixelBlit allows you to render (& scale) a defined area instead of all 64 x 32 pixels!
;-> PixelBlitEx(5,5,20,20) would render 20 x 20 pixels starting from backbuffer position 5 x 5!

End



Download:
https://www.dropbox.com/s/lzdbjjge9juopac/chip8surface_v.1.5.zip?dl=0

_________________

Links:
PureBasic Discord
[ENGINE] 2D Engine Nautilus (Win)
[INCLUDE] GLFW 3.3 Library
[MODULE] Bass Library 2.4 (Win)
[LIBRARY] Hexi Binary2Hex (Win)



Zuletzt geändert von Mijikai am 07.03.2020 16:29, insgesamt 3-mal geändert.

Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags: Re: [LIB] Chip8 Renderer [Windows x64]
BeitragVerfasst: 07.03.2020 13:17 
Offline
Benutzeravatar

Registriert: 10.09.2004 09:59
O.k., das mit dem x64 habe ich offensichtlich übersehen, tut mir Leid.
Vielleicht solltest Du sowas noch im Beispiel integrieren:
Code:
CompilerIf #PB_Compiler_Processor <> #PB_Processor_x64
   CompilerError "Please use x64 compiler!"
CompilerEndIf

Danke auf jeden Fall für das Beispiel, ist zwar nicht mehr so "fancy" wie das erste, dafür macht es die Handhabung jetzt selbst für Deppen wie mich klar :allright:

Eine x86 Version ist nicht geplant?
I.d.R. biete ich meine Apps in beiden Versionen an, das würde die Easteregg Möglichkeiten natürlich einschränken.

_________________
Link tot?
Ändere h3x0r.ath.cx in hex0rs.coderbu.de und alles wird gut.


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags: Re: [LIB] Chip8 Renderer [Windows x64]
BeitragVerfasst: 07.03.2020 16:30 
Offline
Benutzeravatar

Registriert: 25.09.2016 01:42
HeX0R hat geschrieben:
Vielleicht solltest Du sowas noch im Beispiel integrieren:
Code:
CompilerIf #PB_Compiler_Processor <> #PB_Processor_x64
   CompilerError "Please use x64 compiler!"
CompilerEndIf


Habs hinzugefügt und die die Dateien neu hochgeladen :)

HeX0R hat geschrieben:
Eine x86 Version ist nicht geplant?
I.d.R. biete ich meine Apps in beiden Versionen an, das würde die Easteregg Möglichkeiten natürlich einschränken.


Momentan nicht.

_________________

Links:
PureBasic Discord
[ENGINE] 2D Engine Nautilus (Win)
[INCLUDE] GLFW 3.3 Library
[MODULE] Bass Library 2.4 (Win)
[LIBRARY] Hexi Binary2Hex (Win)



Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags: Re: [LIB] Chip8 Renderer [Windows x64]
BeitragVerfasst: 13.03.2020 23:54 
Offline
Benutzeravatar

Registriert: 25.09.2016 01:42
PONG Demo :)

Image:
Bild

Code:
Code:
;CHIP8_SURFACE - A SMALL DIB RENDERER FOR CHIP8 PROJECT
;AUTHOR: MIJIKAI
;VERSION: 1.5

EnableExplicit

Import "chip8surface.lib";v.1.5
  chip8CreateSurface.i(hwnd.i)
EndImport

Interface CHIP8_SURFACE
  PixelClear.i()                                    ;clears the screen / fills the backbuffer with palette 0
  Pixel.i(X.i,Y.i)                                  ;draws a pixel at pos xy using the xy color of palette 1
  PixelEx.i(X.i,Y.i)                                ;same as the function above but with boundary checks
  PixelSetColor.i(X.i,Y.i,Color.i)                  ;draws a pixel at pos xy using the provided color
  PixelSetColorEx.i(X.i,Y.i,Color.i)                ;same as the function above but with boundary checks
  PixelGetColor.i(X.i,Y.i)                          ;get the color at pos xy
  PixelGetColorEx.i(X.i,Y.i)                        ;same as the function above but with boundary checks
  PixelBlit.i()                                     ;flips the buffer / render all drawn pixels
  PixelBlitEx.i(X.i,Y.i,Width.i,Height.i)           ;flips the buffer / only renders the set sub section of drawn pixels
  PixelResize.i()                                   ;scales the render surface while keeping the aspect ratio
  PaletteUpdate.i(Index.i,Color.i,Flag.i)           ;upload custom palette (Index 0 / 1) if flag = 0 color is a palette pointer else a fill color!   
  PaletteSetColor.i(Index.i,X.i,Y.i,Color.i)        ;sets a color at pos xy in the selected palette
  PaletteSetColorEx.i(Index.i,X.i,Y.i,Color.i)      ;same as the function above but with boundary checks
  PaletteGetColor.i(Index.i,X.i,Y.i)                ;gets the color stored at pos xy in the selected palette
  PaletteGetColorEx.i(Index.i,X.i,Y.i)              ;same as the function above but with boundary checks
  PaletteReset.i()                                  ;resets palette 0 and 1
  Clock.i()                                         ;a 16 ms timer useful for rendering / or emulating the cpu clock of chip8
  Release.i()                                       ;free all resources
EndInterface

Structure PONG_POSITION
  x.f
  y.f
EndStructure

Structure PONG_BALL
  pos.PONG_POSITION
  dir.PONG_POSITION
  vel.PONG_POSITION
  mod.PONG_POSITION[28]
EndStructure

Structure PONG_PADDLE
  pos.PONG_POSITION
EndStructure

Structure PONG
  ball.PONG_BALL
  paddle.PONG_PADDLE[2]
  key.i[4]
EndStructure

Procedure.i PongInit(*pong.PONG)
  *pong\ball\pos\x = 31
  *pong\ball\pos\y = Random(16,15)
  Repeat
    *pong\ball\dir\x = -1 + Random(2)
    *pong\ball\dir\y = -1 + Random(2)
  Until *pong\ball\dir\x <> 0 And *pong\ball\dir\y <> 0
  *pong\ball\vel\x = 1
  *pong\ball\vel\y = 0.1
  *pong\paddle[0]\pos\x = 2
  *pong\paddle[0]\pos\y = 12
  *pong\paddle[1]\pos\x = 61
  *pong\paddle[1]\pos\y = 12
  FillMemory(@*pong\ball\mod[0],28,-1082130432,#PB_Long)
  ProcedureReturn #Null
EndProcedure

Procedure.i PongUpdate(*surface.CHIP8_SURFACE,*pong.PONG)
  Protected index.i
  Protected color.i
  Protected drift.f
  ;-----------------------------------------------
  *pong\paddle[0]\pos\y - *pong\key[0]
  *pong\paddle[0]\pos\y + *pong\key[1]
  If *pong\paddle[0]\pos\y < 0
    *pong\paddle[0]\pos\y = 0
  ElseIf *pong\paddle[0]\pos\y > 24
    *pong\paddle[0]\pos\y = 24
  EndIf
  *pong\paddle[1]\pos\y - *pong\key[2]
  *pong\paddle[1]\pos\y + *pong\key[3]
  If *pong\paddle[1]\pos\y < 0
    *pong\paddle[1]\pos\y = 0
  ElseIf *pong\paddle[1]\pos\y > 24
    *pong\paddle[1]\pos\y = 24
  EndIf
  ;-----------------------------------------------
  CopyMemory(@*pong\ball\mod[0],@*pong\ball\mod[1],216)
  *pong\ball\pos\x + (*pong\ball\dir\x * *pong\ball\vel\x)
  *pong\ball\pos\y + (*pong\ball\dir\y * *pong\ball\vel\y)
  ;-----------------------------------------------
  If *pong\ball\pos\x > *pong\paddle[0]\pos\x - 0.1 And *pong\ball\pos\x < *pong\paddle[0]\pos\x + 0.1
    If *pong\ball\pos\y > (*pong\paddle[0]\pos\y - 1) And *pong\ball\pos\y < (*pong\paddle[0]\pos\y + 7.1)
      *pong\ball\dir\x * -1
      drift = Abs(*pong\paddle[0]\pos\y - *pong\ball\pos\y + 3)
    EndIf
  EndIf
  ;-----------------------------------------------
  If *pong\ball\pos\x > *pong\paddle[1]\pos\x - 0.1 And *pong\ball\pos\x < *pong\paddle[1]\pos\x + 0.1
    If *pong\ball\pos\y > (*pong\paddle[1]\pos\y - 0.1) And *pong\ball\pos\y < (*pong\paddle[1]\pos\y + 7.1)
      *pong\ball\dir\x * -1
       drift = Abs(*pong\paddle[1]\pos\y - *pong\ball\pos\y + 3)
    EndIf
  EndIf
  ;-----------------------------------------------
  If drift
    drift / 4
    If drift < 0.1
      drift + 0.1 + (Random(3) / 10)
    EndIf
    *pong\ball\vel\y = drift
  EndIf
  ;-----------------------------------------------
  If *pong\ball\pos\x < 0
    ;*pong\ball\pos\x = 0
    ;*pong\ball\dir\x * -1
    PongInit(*pong)
  ElseIf *pong\ball\pos\x > 63
    ;*pong\ball\pos\x = 63
    ;*pong\ball\dir\x * -1
    PongInit(*pong)
  EndIf
  ;-----------------------------------------------
  If *pong\ball\pos\y < 0
    *pong\ball\pos\y = 0
    *pong\ball\dir\y * -1
  ElseIf *pong\ball\pos\y > 31
    *pong\ball\pos\y = 31
    *pong\ball\dir\y * -1
  EndIf
  ;-----------------------------------------------
  *pong\ball\mod[0]\x = *pong\ball\pos\x
  *pong\ball\mod[0]\y = *pong\ball\pos\y
  For index = 0 To 27
    If *pong\ball\mod[index]\x = -1
      Break
    EndIf
    color = *surface\PaletteGetColorEx(0,*pong\ball\mod[index]\x,15) + $1000 + index
    *surface\PixelSetColorEx(*pong\ball\mod[index]\x,*pong\ball\mod[index]\y,color)
  Next
  *surface\PixelEx(*pong\ball\pos\x,*pong\ball\pos\y)
  ;-----------------------------------------------
  For index = 0 To 7
    *surface\PixelEx(*pong\paddle[0]\pos\x,*pong\paddle[0]\pos\y + index)
    *surface\PixelEx(*pong\paddle[1]\pos\x,*pong\paddle[1]\pos\y + index)
  Next
  ProcedureReturn #Null
EndProcedure

Procedure.i PongInput(*surface.CHIP8_SURFACE,*pong.PONG)
  Protected wnd_event.i
  Protected wnd_exit.i
  Repeat
    wnd_event = WindowEvent()
    Select wnd_event
      Case #WM_KEYDOWN
        Select EventwParam()
          Case #VK_W
            *pong\key[0] = 1
          Case #VK_S
            *pong\key[1] = 1
          Case #VK_P
            *pong\key[2] = 1
          Case #VK_L
            *pong\key[3] = 1
        EndSelect
      Case #WM_KEYUP
        Select EventwParam()
          Case #VK_W
            *pong\key[0] = 0
          Case #VK_S
            *pong\key[1] = 0
          Case #VK_P
            *pong\key[2] = 0
          Case #VK_L
            *pong\key[3] = 0
        EndSelect
      Case #PB_Event_SizeWindow
        *surface\PixelResize()
      Case #PB_Event_CloseWindow
        wnd_exit = 1
    EndSelect
  Until wnd_event = #Null
  ProcedureReturn wnd_exit
EndProcedure

Procedure.i PongSprite(*surface.CHIP8_SURFACE,*Sprite.Ascii,X.i,Y.i,Width.i,Height.i,Color.i)
  Protected px.i
  Protected py.i
  Protected pw.i
  Protected ph.i
  pw = (X + Width) - 1
  ph = (Y + Height) - 1
  For py = Y To ph
    For px = X To pw
      If *Sprite\a
        If Color = 0
          *surface\PixelEx(px,py)
        Else
          *surface\PixelSetColorEx(px,py,Color)
        EndIf
      EndIf
      *Sprite + 1
    Next
  Next
  ProcedureReturn #Null
EndProcedure

Procedure.i Demo(Title.s = #Null$,Width.i = 600,Height.i = 400)
  Protected wnd.i
  Protected wnd_flags.i
  Protected wnd_event.i
  Protected wnd_exit.i
  Protected *surface.CHIP8_SURFACE
  Protected mov.f
  Protected game.PONG
  Protected color1.i
  Protected color2.i
  wnd_flags = #PB_Window_SystemMenu|#PB_Window_ScreenCentered|#PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget|#PB_Window_SizeGadget
  wnd = OpenWindow(#PB_Any,#Null,#Null,Width,Height,Title,wnd_flags)
  If wnd
    WindowBounds(wnd,Width,Height,#PB_Ignore,#PB_Ignore)
    SetWindowColor(wnd,0)
    *surface = chip8CreateSurface(WindowID(wnd))
    If *surface
      PongInit(@game)
      color1 = *surface\PaletteGetColorEx(0,0,0)
      Repeat
        If PongInput(*surface,@game)
          Break 
        EndIf       
        *surface\PixelClear()
        color2 = *surface\PaletteGetColorEx(0,game\ball\pos\x,game\ball\pos\y)
        If color2 = 0
          color2 = color1
        EndIf
        PongSprite(*surface,?sprite,22,13,20,6,color2)
        PongUpdate(*surface,@game)
        *surface\PixelBlit()
        *surface\Clock()
      Until wnd_exit
      *surface\Release()
    EndIf
    CloseWindow(wnd)
  EndIf
  ProcedureReturn #Null
EndProcedure

;PONG DEMO

;CONTROLS:
;-> LEFT  PADDLE: [KEY W] = UP / [KEY S] = DOWN
;-> RIGHT PADDLE: [KEY P] = UP / [KEY L] = DOWN

Demo("PONG")

End

DataSection
  sprite:
  !db 1,1,1,0,0,0,1,1,0,0,1,0,0,1,0,0,1,1,1,0
  !db 1,0,0,1,0,1,0,0,1,0,1,0,0,1,0,1,0,0,0,0
  !db 1,0,0,1,0,1,0,0,1,0,1,1,0,1,0,1,0,0,0,0
  !db 1,1,1,0,0,1,0,0,1,0,1,0,1,1,0,1,0,1,1,0
  !db 1,0,0,0,0,1,0,0,1,0,1,0,0,1,0,1,0,0,1,0
  !db 1,0,0,0,0,0,1,1,0,0,1,0,0,1,0,0,1,1,0,1
EndDataSection

_________________

Links:
PureBasic Discord
[ENGINE] 2D Engine Nautilus (Win)
[INCLUDE] GLFW 3.3 Library
[MODULE] Bass Library 2.4 (Win)
[LIBRARY] Hexi Binary2Hex (Win)



Nach oben
 Profil  
Mit Zitat antworten  
Beiträge der letzten Zeit anzeigen:  Sortiere nach  
Ein neues Thema erstellen Auf das Thema antworten  [ 8 Beiträge ] 

Alle Zeiten sind UTC + 1 Stunde [ Sommerzeit ]


Wer ist online?

Mitglieder in diesem Forum: 0 Mitglieder und 5 Gäste


Sie dürfen keine neuen Themen in diesem Forum erstellen.
Sie dürfen keine Antworten zu Themen in diesem Forum erstellen.
Sie dürfen Ihre Beiträge in diesem Forum nicht ändern.
Sie dürfen Ihre Beiträge in diesem Forum nicht löschen.

Suche nach:
Gehe zu:  

 


Powered by phpBB © 2008 phpBB Group | Deutsche Übersetzung durch phpBB.de
subSilver+ theme by Canver Software, sponsor Sanal Modifiye