This commit is contained in:
parent
4f20a6b400
commit
c76e5d2d73
Binary file not shown.
|
@ -0,0 +1,228 @@
|
|||
{
|
||||
Multi core transform sample
|
||||
|
||||
derived from "3D Graphics DEMO" by Beau Schwabe (Parallax)
|
||||
}
|
||||
|
||||
CON
|
||||
' enable multi core transform calculation
|
||||
MultiCoreTranform = true
|
||||
|
||||
ZX = 180
|
||||
ZY = 240
|
||||
|
||||
MaxPoints = 50
|
||||
|
||||
_CLKMODE = XTAL1 + PLL16X
|
||||
_XINFREQ = 5_000_000
|
||||
_stack = ($3000 + $3000 + 100) >> 2
|
||||
|
||||
x_tiles = 16
|
||||
y_tiles = 12
|
||||
|
||||
paramcount = 14
|
||||
bitmap_base = $2000
|
||||
display_base = $5000
|
||||
|
||||
|
||||
VAR
|
||||
long tv_status '0/1/2 = off/visible/invisible read-only
|
||||
long tv_enable '0/? = off/on write-only
|
||||
long tv_pins '%ppmmm = pins write-only
|
||||
long tv_mode '%ccinp = chroma,interlace,ntsc/pal,swap write-only
|
||||
long tv_screen 'pointer to screen (words) write-only
|
||||
long tv_colors 'pointer to colors (longs) write-only
|
||||
long tv_hc 'horizontal cells write-only
|
||||
long tv_vc 'vertical cells write-only
|
||||
long tv_hx 'horizontal cell expansion write-only
|
||||
long tv_vx 'vertical cell expansion write-only
|
||||
long tv_ho 'horizontal offset write-only
|
||||
long tv_vo 'vertical offset write-only
|
||||
long tv_broadcast 'broadcast frequency (Hz) write-only
|
||||
long tv_auralcog 'aural fm cog write-only
|
||||
|
||||
word screen[x_tiles * y_tiles]
|
||||
long colors[64]
|
||||
|
||||
long cogStack[40 * 5]
|
||||
long pointData[MaxPoints * 5]
|
||||
byte frame
|
||||
|
||||
|
||||
OBJ
|
||||
tv : "tv" 'located in default Library
|
||||
gr : "PF_graphics" 'located in default Library
|
||||
|
||||
|
||||
PUB start | i,dx,dy
|
||||
'start tv
|
||||
longmove(@tv_status, @tvparams, paramcount)
|
||||
tv_screen := @screen
|
||||
tv_colors := @colors
|
||||
tv.start(@tv_status)
|
||||
|
||||
'init colors
|
||||
repeat i from 0 to 63
|
||||
colors[i] := $ad02ad06
|
||||
|
||||
'init tile screen
|
||||
i := 0
|
||||
repeat dy from 0 to tv_vc - 1
|
||||
repeat dx from 0 to tv_hc - 1
|
||||
screen[i++] := display_base >> 6 + dy + dx * tv_vc + (dy << 10)
|
||||
|
||||
'start and setup graphics
|
||||
gr.start
|
||||
gr.setup(tv_hc, tv_vc, tv_hc<<3, tv_vc<<3, bitmap_base)
|
||||
|
||||
'Start transform routines (per object)
|
||||
if MultiCoreTranform
|
||||
repeat i from 0 to 4
|
||||
cognew( Polyobj(@pointData[ MaxPoints * i ], @PostureData + i * 20), @cogStack[i * 40] )
|
||||
|
||||
MainLoop
|
||||
|
||||
|
||||
PRI MainLoop | i, n, t
|
||||
n := 0
|
||||
t := cnt & |<27
|
||||
repeat
|
||||
gr.clear
|
||||
gr.width(0)
|
||||
|
||||
repeat i from 0 to n
|
||||
if !MultiCoreTranform
|
||||
TranslatePoints( @pointData[ MaxPoints * i ], @PostureData + i * 20, @PointSrc, constant((@PointSrc_End - @PointSrc)/3) )
|
||||
repeat until ( word[ @PostureData + i * 20 + 18] == frame )
|
||||
gr.lineseq( @pointData[MaxPoints * i], @SeqData)
|
||||
|
||||
gr.copy(display_base)
|
||||
frame++
|
||||
|
||||
if ( t <> cnt & |<27 )
|
||||
t := cnt & |<27
|
||||
n := (n + 1) <# 4
|
||||
|
||||
'wait Vsync
|
||||
repeat until ( tv_status == 1 )
|
||||
|
||||
|
||||
PRI PolyObj(destAddr, postureAddr)
|
||||
repeat
|
||||
repeat while word[ postureAddr + 18 ] == frame
|
||||
TranslatePoints( destAddr, postureAddr, @PointSrc, constant((@PointSrc_End - @PointSrc)/3) )
|
||||
|
||||
|
||||
PRI TranslatePoints( destAddr, postureAddr, pointAddr, numPoints ) | i,dst,px,py,pz,tx,ty,tz,dx,dy,dz,S1,S2,S3,C1,C2,C3,x,y,z
|
||||
tx := ( word[ postureAddr + 6 ] += word[ postureAddr + 12 ] )
|
||||
ty := ( word[ postureAddr + 8 ] += word[ postureAddr + 14 ] )
|
||||
tz := ( word[ postureAddr + 10 ] += word[ postureAddr + 16 ] )
|
||||
|
||||
S1 := Sin(tx)
|
||||
S2 := Sin(ty)
|
||||
S3 := Sin(tz)
|
||||
|
||||
C1 := Cos(tx)
|
||||
C2 := Cos(ty)
|
||||
C3 := Cos(tz)
|
||||
|
||||
x := ~word[ postureAddr + 0 ]
|
||||
y := ~word[ postureAddr + 2 ]
|
||||
z := word[ postureAddr + 4 ] + (C1 ~> 9) ' add C1~>9 for test
|
||||
|
||||
repeat i from 0 to numPoints
|
||||
px := ~byte[pointAddr++]
|
||||
py := ~byte[pointAddr++]
|
||||
pz := ~byte[pointAddr++]
|
||||
|
||||
tx := ( px * C2 - pz * S2 ) ~> 16
|
||||
tz := ( px * S2 + pz * C2 ) ~> 16
|
||||
ty := ( tz * S1 + py * C1 ) ~> 16
|
||||
|
||||
dx := ( tx * C3 + ty * S3 ) ~> 16 + x
|
||||
dy := ( ty * C3 - tx * S3 ) ~> 16 + y
|
||||
dz := ( tz * C1 - py * S1 ) ~> 16 + z
|
||||
|
||||
word[destAddr ] := dx * ZX / dz
|
||||
word[destAddr+2] := dy * ZY / dz
|
||||
destAddr += 4
|
||||
|
||||
word[ postureAddr + 18 ] := frame
|
||||
|
||||
|
||||
pri cos(angle) : x
|
||||
x := sin(angle + $800)
|
||||
|
||||
|
||||
pri sin(angle) : y
|
||||
'' Get sine of angle (0-8191)
|
||||
y := angle << 1 & $FFE ' address
|
||||
if angle & $800
|
||||
y := word[$F000 - y]
|
||||
else
|
||||
y := word[$E000 + y]
|
||||
if angle & $1000
|
||||
-y
|
||||
|
||||
|
||||
DAT
|
||||
PostureData
|
||||
' trans rot rotspeed sync
|
||||
word 0, 0, 400, 0, 0, 0, 0, 0, 200, 0
|
||||
word -120, -80, 400, 0, 0, 0, 50, 30, 40, 0
|
||||
word -120, 80, 400, 0, 0, 0, 40, 50, 30, 0
|
||||
word 120, -80, 400, 0, 0, 0, 30, 50, 40, 0
|
||||
word 120, 80, 400, 0, 0, 0, 50, 40, 30, 0
|
||||
|
||||
PointSrc
|
||||
byte -20,-20,-20
|
||||
byte -20,-20, 20
|
||||
byte -20, 20, 20
|
||||
byte -20, 20,-20
|
||||
byte 20,-20,-20
|
||||
byte 20,-20, 20
|
||||
byte 20, 20, 20
|
||||
byte 20, 20,-20
|
||||
|
||||
byte -40,-40,-40
|
||||
byte -40,-40, 40
|
||||
byte -40, 40, 40
|
||||
byte -40, 40,-40
|
||||
byte 40,-40,-40
|
||||
byte 40,-40, 40
|
||||
byte 40, 40, 40
|
||||
byte 40, 40,-40
|
||||
|
||||
byte -70, 0, 0
|
||||
byte 70, 0, 0
|
||||
PointSrc_End
|
||||
|
||||
SeqData
|
||||
' orange thing
|
||||
byte 13, 1, 16, 0, 4, 17, 5, 1, 16, 2, 6, 17, 7, 3, 16
|
||||
byte 5, 1, 0, 1, 2, 3, 0
|
||||
byte 5, 1, 4, 5, 6, 7, 4
|
||||
' black cube
|
||||
byte 10, 2, 8, 9,10,11, 8,12,13,14,15,12
|
||||
byte 2, 2, 9,13
|
||||
byte 2, 2,10,14
|
||||
byte 2, 2,11,15
|
||||
byte 0
|
||||
|
||||
|
||||
tvparams long 0 'status
|
||||
long 1 'enable
|
||||
'long %011_0000 'pins Old Board
|
||||
long %010_0101 'pins New Board
|
||||
long %0000 'mode
|
||||
long 0 'screen
|
||||
long 0 'colors
|
||||
long x_tiles 'hc
|
||||
long y_tiles 'vc
|
||||
long 10 'hx
|
||||
long 1 'vx
|
||||
long 0 'ho
|
||||
long 0 'vo
|
||||
long 60_000_000 '_xinfreq<<4 'broadcast
|
||||
long 0 'auralcog
|
||||
|
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,17 @@
|
|||
BST Propeller Archive
|
||||
Created by Brads Spin Tool Compiler v0.15.4-pre5 - Copyright 2008,2009,2010 All rights reserved
|
||||
Compiled for i386 Win32 at 14:24:31 on 2010/03/10
|
||||
|
||||
Archive Created at 13:56:49 On 06/05/10
|
||||
Included Objects :
|
||||
3d_multicore
|
||||
|
|
||||
+-----tv
|
||||
|
|
||||
+-----PF_graphics
|
||||
|
||||
,
|
||||
- 3d_multicore.spin
|
||||
- TV.spin
|
||||
- PF_Graphics.spin
|
||||
,
|
|
@ -0,0 +1 @@
|
|||
http://propfan.wordpress.com/page/2/
|
Binary file not shown.
|
@ -0,0 +1,115 @@
|
|||
''***************************************
|
||||
''* VGA Tile + Sprite Driver Demo v1.0 *
|
||||
''* (C) Jim Bagley *
|
||||
''***************************************
|
||||
|
||||
_clkmode = xtal1 + pll16x ' enable external clock and pll times 16
|
||||
_xinfreq = 5_000_000 ' set frequency to 5 MHZ
|
||||
|
||||
CON
|
||||
|
||||
NUM_COGS = 3 'if not using sprites, you can set this to 1 :)
|
||||
NUM_SPRITES = 32 '64 'buffer is 3 words ( X,Y,TILENUM), so use even numbers.
|
||||
|
||||
OBJ
|
||||
vga : "VGA_JB_001"
|
||||
rend : "VGA_REND_JB_001"
|
||||
|
||||
PUB start | i,c,x,y
|
||||
vga.start(@vga_params)
|
||||
rend.start(@rend_params)
|
||||
|
||||
repeat y from 0 to 29
|
||||
repeat x from 0 to 63
|
||||
PutChar(x,y,word[@map][y*64+x])
|
||||
|
||||
print(0,0,string("Hallo Welt"))
|
||||
|
||||
c:=$deadface
|
||||
if NUM_SPRITES>0
|
||||
repeat i from 0 to rend_num_sprites-1 step 2
|
||||
x:=c?
|
||||
y:=c?
|
||||
SetSprite(i ,x ,y,0)
|
||||
SetSprite(i+1,x+4,y,1)
|
||||
' SetSprite(i,4+i*3,8+i*2,0)
|
||||
|
||||
repeat
|
||||
repeat while vga_params<>1
|
||||
repeat while vga_params==1
|
||||
if NUM_SPRITES>0
|
||||
wordmove(@sprite_list,@sprite_list2,3*rend_num_sprites)
|
||||
repeat i from 0 to rend_num_sprites-1
|
||||
sprite_list2[i*3+0]++
|
||||
sprite_list2[i*3+1]++
|
||||
|
||||
PUB print(x,y,str) | c,a
|
||||
repeat
|
||||
c:=byte[str++]
|
||||
if(c==0)
|
||||
return
|
||||
a:=-1
|
||||
if(c>"A"-1) and (c<"Z"+1)
|
||||
a:=(c-"A")+10
|
||||
if(c>"a"-1) and (c<"z"+1)
|
||||
a:=(c-"a")+10
|
||||
if(c>"0"-1) and (c<"9"+1)
|
||||
a:=c-"0"
|
||||
if(a==-1)
|
||||
screen[y<<6+x++]:=0
|
||||
screen[y<<6+x++]:=0
|
||||
else
|
||||
a:=(a<<6)+(@font-@chars) '*64 ( 2 4x8 chars per letter ) + offset from chars to font
|
||||
screen[y<<6+x++]:=a
|
||||
screen[y<<6+x++]:=a+32
|
||||
|
||||
PUB PutChar(x,y,charnum)
|
||||
screen[y<<6+x]:=charnum<<5
|
||||
|
||||
PUB SetSprite(sprnum,x,y,tilenum)
|
||||
sprite_list2[sprnum*3+0]:=x
|
||||
sprite_list2[sprnum*3+1]:=y
|
||||
sprite_list2[sprnum*3+2]:=tilenum<<5
|
||||
|
||||
DAT
|
||||
|
||||
rend_params
|
||||
rend_cognum long 0
|
||||
rend_image long 0
|
||||
rend_pixels long @pixelsdata+$10 'pointer to line buffers ( (256+8)*rendercogs )
|
||||
rend_screen long @screen+$10 'pointer to screen charmap buffer ( 64x30 )
|
||||
rend_chars long @chars+$10 'pointer to screen character image tiles ( 4x8 )
|
||||
rend_sprite_ptr long @sprite_list+$10 'pointer to sprite list ( X,Y,CHR )
|
||||
rend_sprchr_ptr long @sprchrs+$10 'pointer to sprite image tiles ( 4x8 )
|
||||
rend_num_sprites long NUM_SPRITES
|
||||
'vga_params falls after rend_params
|
||||
vga_params long 0 'sync
|
||||
vga_pixels long @pixelsdata+$10 'pointer to line buffers
|
||||
vga_nextlineptr long @next_line+$10 'pointer to nextline to be draw
|
||||
vga_enable long 1 'enable display
|
||||
vga_cogs long NUM_COGS 'number of display lines before looping to top of buffer
|
||||
|
||||
sprite_list word 0[3*NUM_SPRITES] '4 words as it reads data in longs
|
||||
sprite_list2 word 0[3*NUM_SPRITES] '4 words as it reads data in longs
|
||||
|
||||
next_line long 0
|
||||
|
||||
pixelsdata byte 0[(256+8)*NUM_COGS]
|
||||
|
||||
screen word 0*32[64*30] 'Character map layout, TILENUM*32, as you can use pixel offsets into chars if you want, or set the charset to 0, and use as pointer to area
|
||||
|
||||
chars file "mario.chr"
|
||||
|
||||
sprchrs
|
||||
font file "font.chr"
|
||||
|
||||
byte $0f,$0f,$0f,$0f
|
||||
byte $0f,$03,$03,$0f
|
||||
byte $0f,$ff,$ff,$0f
|
||||
byte $0f,$ff,$ff,$0f
|
||||
byte $0f,$ff,$ff,$0f
|
||||
byte $0f,$ff,$ff,$0f
|
||||
byte $0f,$03,$03,$0f
|
||||
byte $0f,$0f,$0f,$0f
|
||||
|
||||
map file "mario.map"
|
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,966 @@
|
|||
#include "stdio.h"
|
||||
|
||||
unsigned short header[0x36];
|
||||
unsigned char palette[256*4];
|
||||
unsigned char proppal[256];
|
||||
|
||||
unsigned char charcell[8*8];
|
||||
unsigned char convchar[8*8];
|
||||
unsigned short currentattr;
|
||||
|
||||
unsigned short currentblock;
|
||||
unsigned short blockcell[4];
|
||||
unsigned short blockmap[10240*10240];
|
||||
unsigned short blocks[40960*64];
|
||||
unsigned short charmap[5120*5120];
|
||||
unsigned char chars[20480*64];
|
||||
unsigned int charnum;
|
||||
unsigned int blocknum;
|
||||
unsigned int blockmapsize=1;
|
||||
unsigned int blocksize=1;
|
||||
int yfirst=0;
|
||||
int justcharmap=0;
|
||||
int invx=0;
|
||||
int nopalette=0;
|
||||
int pal16=0;
|
||||
int getting_2600=0;
|
||||
|
||||
#define bitmap2 0
|
||||
#define bitmap4 1
|
||||
#define bitmap16 2
|
||||
#define bitmap256 3
|
||||
#define C64bitmap2 4
|
||||
#define C64bitmap4 5
|
||||
#define AMSbitmap4 6
|
||||
#define AMSbitmap16 7
|
||||
#define charmap2 8
|
||||
#define charmap4 9
|
||||
#define charmap16 10
|
||||
#define charmap256 11
|
||||
#define C64sprites 12
|
||||
#define VGAchars4x8 13
|
||||
|
||||
int charand=0x03;
|
||||
int paland=0xfc;
|
||||
int palshift=2;
|
||||
int mode=charmap4;
|
||||
int fat=0;
|
||||
|
||||
int repeatable=0;
|
||||
int flipable=0;
|
||||
|
||||
char extjcs[]="JCS"; //c64 mode sprites
|
||||
char extcb2[]="CB2"; //c64 mode bitmap2col
|
||||
char extcb4[]="CB4"; //c64 mode bitmap4col
|
||||
char extjcc[]="JCC"; //c64 mode characters
|
||||
|
||||
char extab4[]="AB4"; //Ams mode 4colour bitmap
|
||||
char exta16[]="A16"; //Ams mode 16colour fat bitmap
|
||||
char extas4[]="AS4"; //Ams mode 4colour sprite
|
||||
char extas6[]="AS6"; //Ams mode 16colour fat sprite
|
||||
|
||||
char extjb2[]="JB2";
|
||||
char extjb4[]="JB4";
|
||||
char extj16[]="J16";
|
||||
char extj8b[]="J8B";
|
||||
char extbm2[]="BM2";
|
||||
char extbm4[]="BM4";
|
||||
char extb16[]="B16";
|
||||
char extb8b[]="B8B";
|
||||
char extvga[]="VGA";
|
||||
char *ext=extjb4;
|
||||
|
||||
char fname[1024];
|
||||
unsigned char screen[4096*4096];
|
||||
|
||||
unsigned int scrwidth;
|
||||
unsigned int scrheight;
|
||||
|
||||
int doingvga;
|
||||
|
||||
unsigned char PropRGBs[256*4]={
|
||||
0x04,0x05,0x05,0x00, 0x02,0x04,0x04,0x00, 0x04,0x06,0x06,0x00, 0x31,0x34,0x33,0x00, 0x64,0x66,0x66,0x00, 0x97,0x9b,0x9b,0x00, 0xcf,0xd0,0xd0,0x00, 0xf0,0xf9,0xfa,0x00, 0x29,0x8c,0xa1,0x00, 0x44,0x0a,0x0e,0x00, 0x75,0x00,0x00,0x00, 0x9f,0x2c,0x26,0x00, 0xd4,0x63,0x5c,0x00, 0xfb,0x97,0x90,0x00, 0xf4,0xc5,0xbe,0x00, 0x23,0x5e,0x72,0x00,
|
||||
0x02,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x03,0x05,0x05,0x00, 0x30,0x33,0x33,0x00, 0x62,0x65,0x65,0x00, 0x96,0x99,0x99,0x00, 0xcd,0xce,0xcd,0x00, 0xef,0xf7,0xfb,0x00, 0x21,0x7b,0xd7,0x00, 0x3c,0x07,0x19,0x00, 0x6f,0x06,0x00,0x00, 0x97,0x33,0x11,0x00, 0xcc,0x69,0x43,0x00, 0xfe,0x9e,0x75,0x00, 0xf6,0xc9,0xa8,0x00, 0x1e,0x4c,0xa9,0x00,
|
||||
0x02,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x03,0x05,0x05,0x00, 0x30,0x33,0x33,0x00, 0x62,0x66,0x65,0x00, 0x96,0x9a,0x99,0x00, 0xcd,0xcf,0xcd,0x00, 0xf1,0xf6,0xfd,0x00, 0x25,0x66,0xf4,0x00, 0x21,0x04,0x21,0x00, 0x4b,0x0e,0x00,0x00, 0x77,0x3d,0x02,0x00, 0xac,0x73,0x2d,0x00, 0xe3,0xa9,0x5e,0x00, 0xf3,0xd1,0x95,0x00, 0x1f,0x36,0xdc,0x00,
|
||||
0x02,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x03,0x05,0x04,0x00, 0x30,0x33,0x33,0x00, 0x62,0x66,0x65,0x00, 0x95,0x99,0x99,0x00, 0xcc,0xcf,0xcd,0x00, 0xf4,0xf5,0xfd,0x00, 0x47,0x54,0xf7,0x00, 0x08,0x03,0x22,0x00, 0x1d,0x16,0x00,0x00, 0x4c,0x45,0x01,0x00, 0x80,0x7b,0x23,0x00, 0xb8,0xb1,0x51,0x00, 0xe0,0xd8,0x8a,0x00, 0x23,0x24,0xef,0x00,
|
||||
0x02,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x03,0x05,0x04,0x00, 0x30,0x33,0x33,0x00, 0x62,0x65,0x65,0x00, 0x96,0x99,0x99,0x00, 0xca,0xcf,0xcc,0x00, 0xf9,0xf4,0xfd,0x00, 0xad,0x47,0xf7,0x00, 0x14,0x05,0x23,0x00, 0x02,0x1c,0x00,0x00, 0x1e,0x4a,0x01,0x00, 0x52,0x80,0x22,0x00, 0x85,0xb7,0x50,0x00, 0xb8,0xdd,0x88,0x00, 0x7c,0x1d,0xf0,0x00,
|
||||
0x01,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x03,0x05,0x05,0x00, 0x30,0x33,0x33,0x00, 0x63,0x66,0x65,0x00, 0x96,0x9a,0x99,0x00, 0xc9,0xd0,0xcc,0x00, 0xfc,0xf3,0xfc,0x00, 0xf4,0x41,0xf7,0x00, 0x24,0x05,0x23,0x00, 0x00,0x1e,0x00,0x00, 0x02,0x4c,0x01,0x00, 0x28,0x82,0x2a,0x00, 0x55,0xb9,0x5a,0x00, 0x90,0xdd,0x90,0x00, 0xe6,0x1c,0xdf,0x00,
|
||||
0x01,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x03,0x05,0x05,0x00, 0x30,0x33,0x33,0x00, 0x63,0x66,0x65,0x00, 0x96,0x9a,0x99,0x00, 0xca,0xd0,0xcd,0x00, 0xfc,0xf3,0xfa,0x00, 0xfd,0x49,0xe3,0x00, 0x28,0x06,0x20,0x00, 0x00,0x1b,0x00,0x00, 0x00,0x4a,0x0c,0x00, 0x09,0x7f,0x3d,0x00, 0x31,0xb6,0x6f,0x00, 0x70,0xdb,0xa1,0x00, 0xf6,0x1c,0xb2,0x00,
|
||||
0x01,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x03,0x05,0x05,0x00, 0x30,0x33,0x33,0x00, 0x62,0x65,0x65,0x00, 0x96,0x99,0x99,0x00, 0xca,0xcf,0xce,0x00, 0xfc,0xf3,0xf6,0x00, 0xfb,0x5b,0xa8,0x00, 0x29,0x06,0x15,0x00, 0x00,0x15,0x00,0x00, 0x00,0x44,0x21,0x00, 0x00,0x79,0x57,0x00, 0x1d,0xb0,0x8a,0x00, 0x5e,0xd5,0xb6,0x00, 0xf2,0x28,0x72,0x00,
|
||||
0x02,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x03,0x05,0x05,0x00, 0x30,0x33,0x33,0x00, 0x62,0x65,0x65,0x00, 0x96,0x99,0x99,0x00, 0xc9,0xcf,0xcf,0x00, 0xfc,0xf4,0xf4,0x00, 0xfb,0x6f,0x63,0x00, 0x29,0x09,0x07,0x00, 0x00,0x0d,0x0e,0x00, 0x00,0x3c,0x3d,0x00, 0x00,0x72,0x73,0x00, 0x1b,0xa7,0xaa,0x00, 0x5d,0xce,0xd0,0x00, 0xf2,0x3c,0x2f,0x00,
|
||||
0x01,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x03,0x05,0x04,0x00, 0x30,0x33,0x33,0x00, 0x63,0x65,0x65,0x00, 0x96,0x99,0x99,0x00, 0xca,0xcf,0xd0,0x00, 0xfc,0xf6,0xf1,0x00, 0xfc,0x83,0x29,0x00, 0x28,0x0d,0x0a,0x00, 0x00,0x03,0x2a,0x00, 0x00,0x32,0x58,0x00, 0x06,0x68,0x8e,0x00, 0x2b,0x9d,0xc4,0x00, 0x6c,0xc6,0xe8,0x00, 0xf4,0x50,0x1c,0x00,
|
||||
0x02,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x02,0x05,0x04,0x00, 0x30,0x33,0x33,0x00, 0x62,0x65,0x65,0x00, 0x96,0x9a,0x99,0x00, 0xca,0xce,0xd0,0x00, 0xfc,0xf7,0xf0,0x00, 0xfa,0x98,0x20,0x00, 0x26,0x10,0x19,0x00, 0x00,0x00,0x41,0x00, 0x00,0x29,0x6d,0x00, 0x20,0x5e,0xa2,0x00, 0x4d,0x93,0xd9,0x00, 0x89,0xbe,0xef,0x00, 0xf0,0x65,0x1c,0x00,
|
||||
0x02,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x03,0x05,0x05,0x00, 0x30,0x33,0x33,0x00, 0x62,0x65,0x65,0x00, 0x96,0x9a,0x99,0x00, 0xca,0xce,0xd0,0x00, 0xfa,0xf8,0xf0,0x00, 0xc3,0xa9,0x21,0x00, 0x18,0x12,0x23,0x00, 0x00,0x00,0x4e,0x00, 0x17,0x22,0x79,0x00, 0x48,0x57,0xae,0x00, 0x7b,0x8b,0xe5,0x00, 0xb0,0xb8,0xf1,0x00, 0x96,0x78,0x1c,0x00,
|
||||
0x01,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x03,0x05,0x05,0x00, 0x30,0x33,0x33,0x00, 0x62,0x65,0x65,0x00, 0x96,0x9a,0x99,0x00, 0xcc,0xce,0xd0,0x00, 0xf5,0xf9,0xf0,0x00, 0x57,0xb5,0x21,0x00, 0x07,0x14,0x22,0x00, 0x15,0x00,0x4f,0x00, 0x41,0x1d,0x7a,0x00, 0x78,0x52,0xaf,0x00, 0xad,0x85,0xe6,0x00, 0xd9,0xb4,0xf2,0x00, 0x2e,0x85,0x1d,0x00,
|
||||
0x01,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x03,0x05,0x05,0x00, 0x30,0x33,0x33,0x00, 0x62,0x65,0x65,0x00, 0x96,0x9a,0x99,0x00, 0xcd,0xce,0xd0,0x00, 0xf1,0xfa,0xf1,0x00, 0x27,0xba,0x22,0x00, 0x1b,0x14,0x1a,0x00, 0x41,0x00,0x45,0x00, 0x6d,0x1c,0x6f,0x00, 0xa3,0x50,0xa5,0x00, 0xdb,0x83,0xdb,0x00, 0xf1,0xb3,0xf1,0x00, 0x1e,0x8a,0x1f,0x00,
|
||||
0x02,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x03,0x05,0x05,0x00, 0x30,0x33,0x33,0x00, 0x62,0x65,0x65,0x00, 0x96,0x9a,0x99,0x00, 0xcd,0xce,0xd0,0x00, 0xef,0xfa,0xf3,0x00, 0x22,0xb3,0x28,0x00, 0x36,0x12,0x0b,0x00, 0x67,0x00,0x30,0x00, 0x91,0x1e,0x5c,0x00, 0xc5,0x53,0x92,0x00, 0xfa,0x86,0xc8,0x00, 0xf6,0xb5,0xed,0x00, 0x1f,0x83,0x21,0x00,
|
||||
0x02,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x03,0x05,0x05,0x00, 0x30,0x33,0x33,0x00, 0x62,0x65,0x65,0x00, 0x95,0x9a,0x99,0x00, 0xcd,0xce,0xcf,0x00, 0xef,0xf9,0xf6,0x00, 0x22,0xa1,0x56,0x00, 0x46,0x0e,0x02,0x00, 0x7b,0x00,0x15,0x00, 0xa3,0x23,0x43,0x00, 0xd7,0x58,0x78,0x00, 0xff,0x8b,0xaf,0x00, 0xf5,0xba,0xd8,0x00, 0x1f,0x74,0x2c,0x00,
|
||||
};
|
||||
|
||||
unsigned char colours_bmp[86*3]={
|
||||
0x78,0x02,0x2a,0x83,0x0b,0x09,0x6e,0x39,0x1a,0x3b,0x2b,0x13,0x2c,0x29,0x1d,0x27,0x30,0x20,0x15,0x3f,0x11,0x14,0x35,0x1c,0x11,0x36,0x2f,0x13,0x3a,0x48,0x0e,0x37,0x58,0x07,0x22,0x73,0x1f,0x14,0x67,0x48,0x1e,0x74,0x45,0x11,0x4f,0x65,0x0f,0x42,
|
||||
0xb7,0x09,0x45,0xa8,0x13,0x12,0xa1,0x54,0x25,0x79,0x57,0x22,0x6b,0x62,0x41,0x57,0x6b,0x44,0x27,0x7b,0x1c,0x24,0x69,0x37,0x1f,0x68,0x5a,0x20,0x5e,0x72,0x14,0x4f,0x7b,0x0e,0x33,0xa1,0x32,0x25,0x9c,0x60,0x2b,0x98,0x6c,0x1a,0x79,0x96,0x1a,0x66,
|
||||
0xcf,0x4a,0x79,0xc0,0x4f,0x4d,0xc0,0x72,0x40,0xac,0x7c,0x2e,0xa0,0x8f,0x4f,0x85,0x9c,0x6d,0x3a,0xa2,0x32,0x42,0xa6,0x69,0x4c,0xa5,0x94,0x42,0x84,0x9f,0x37,0x76,0xa3,0x4c,0x6e,0xb8,0x7f,0x73,0xbc,0x91,0x68,0xb8,0x9d,0x43,0xac,0xc9,0x5a,0x9f,
|
||||
0xcb,0x8b,0xa3,0xbe,0x81,0x7e,0xc0,0x8d,0x6d,0xbe,0x9f,0x6c,0xbb,0xae,0x7f,0xa2,0xb4,0x8e,0x7b,0xb8,0x78,0x75,0xbd,0x92,0x86,0xb6,0xad,0x72,0xa0,0xb6,0x7b,0xa0,0xbc,0x91,0xa0,0xc0,0x9e,0x97,0xbb,0xa7,0x8d,0xbe,0xb5,0x85,0xbc,0xcb,0x85,0xb0,
|
||||
0xd7,0xb3,0xc0,0xca,0xa8,0xa8,0xcc,0xb4,0xa5,0xcc,0xbb,0xa2,0xc9,0xc3,0xaf,0xbf,0xca,0xb2,0xb5,0xcb,0xb3,0xb3,0xcc,0xbe,0xb0,0xcb,0xc8,0xa8,0xc0,0xcb,0xa5,0xba,0xca,0xb2,0xba,0xcc,0xb9,0xb4,0xcb,0xbd,0xaf,0xca,0xc5,0xb2,0xc8,0xd6,0xb7,0xcb,
|
||||
0x00,0x00,0x00,0x33,0x33,0x33,0x77,0x77,0x77,0xaa,0xaa,0xaa,0xee,0xee,0xee,0xff,0xff,0xff,
|
||||
};
|
||||
|
||||
unsigned char colours_idx[86]={
|
||||
0x0a,0x1a,0x2a,0x3a,0x4a,0x5a,0x6a,0x7a,0x8a,0x9a,0xaa,0xba,0xca,0xda,0xea,0xfa,
|
||||
0x0b,0x1b,0x2b,0x3b,0x4b,0x5b,0x6b,0x7b,0x8b,0x9b,0xab,0xbb,0xcb,0xdb,0xeb,0xfb,
|
||||
0x0c,0x1c,0x2c,0x3c,0x4c,0x5c,0x6c,0x7c,0x8c,0x9c,0xac,0xbc,0xcc,0xdc,0xec,0xfc,
|
||||
0x0d,0x1d,0x2d,0x3d,0x4d,0x5d,0x6d,0x7d,0x8d,0x9d,0xad,0xbd,0xcd,0xdd,0xed,0xfd,
|
||||
0x0e,0x1e,0x2e,0x3e,0x4e,0x5e,0x6e,0x7e,0x8e,0x9e,0xae,0xbe,0xce,0xde,0xee,0xfe,
|
||||
0x02,0x03,0x04,0x05,0x06,0x07
|
||||
};
|
||||
unsigned char propcolours[256];
|
||||
|
||||
unsigned char getpixelcolour(int r,int g,int b)
|
||||
{
|
||||
int tr,tg,tb;
|
||||
int i,d,t;
|
||||
unsigned char c;
|
||||
if(doingvga)
|
||||
if(r==255 && g==0 && b==255) return 0;
|
||||
return ((r>>6)<<2)+((g>>6)<<4)+((b>>6)<<6)+3;
|
||||
c=80;
|
||||
d=10000;
|
||||
|
||||
for(i=0;i<256;i++)
|
||||
{
|
||||
tr=PropRGBs[i*4+0]-r;
|
||||
tg=PropRGBs[i*4+1]-g;
|
||||
tb=PropRGBs[i*4+2]-b;
|
||||
tr=abs(tr);
|
||||
tg=abs(tg);
|
||||
tb=abs(tb);
|
||||
t=tr;
|
||||
if(tg>t) t=tg;
|
||||
if(tb>t) t=tb;
|
||||
|
||||
if (t<d)
|
||||
{
|
||||
d=t;
|
||||
c=i;
|
||||
}
|
||||
}
|
||||
if(c&15<7) c=c&15;
|
||||
if(c<2) c=2;
|
||||
return c;
|
||||
|
||||
|
||||
for(i=0;i<86;i++)
|
||||
{
|
||||
tr=colours_bmp[i*3+0]-r;
|
||||
tg=colours_bmp[i*3+1]-g;
|
||||
tb=colours_bmp[i*3+2]-b;
|
||||
tr=abs(tr);
|
||||
tg=abs(tg);
|
||||
tb=abs(tb);
|
||||
t=tr;
|
||||
if(tg>t) t=tg;
|
||||
if(tb>t) t=tb;
|
||||
|
||||
if (t<d)
|
||||
{
|
||||
d=t;
|
||||
c=i;
|
||||
}
|
||||
}
|
||||
return colours_idx[c];
|
||||
}
|
||||
|
||||
void setuppropcolours(void)
|
||||
{
|
||||
FILE *f;
|
||||
int x,y;
|
||||
f=fopen("propcolours.bmp","rb");
|
||||
if(f)
|
||||
{
|
||||
fseek(f,0x36,SEEK_SET);
|
||||
fread(colours_bmp,86,3,f);
|
||||
fclose(f);
|
||||
}
|
||||
for(x=2;x<=7;x++) propcolours[x]=x;
|
||||
for(x=11;x<=14;x++)
|
||||
{
|
||||
for(y=0;y<16;y++)
|
||||
{
|
||||
propcolours[x*16+y]=y*16+x;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void convcharto1bit(int chr)
|
||||
{
|
||||
unsigned char *src=&chars[chr*64];
|
||||
unsigned char *dst=&convchar[0];
|
||||
int i;
|
||||
for(i=0;i<64;i++)
|
||||
{
|
||||
if((i&7)==0) dst[i>>3] =((src[i]&1)<<0);
|
||||
if((i&7)==1) dst[i>>3]|=((src[i]&1)<<1);
|
||||
if((i&7)==2) dst[i>>3]|=((src[i]&1)<<2);
|
||||
if((i&7)==3) dst[i>>3]|=((src[i]&1)<<3);
|
||||
if((i&7)==4) dst[i>>3]|=((src[i]&1)<<4);
|
||||
if((i&7)==5) dst[i>>3]|=((src[i]&1)<<5);
|
||||
if((i&7)==6) dst[i>>3]|=((src[i]&1)<<6);
|
||||
if((i&7)==7) dst[i>>3]|=((src[i]&1)<<7);
|
||||
}
|
||||
}
|
||||
|
||||
void convcharto2bit(int chr)
|
||||
{
|
||||
unsigned char *src=&chars[chr*64];
|
||||
unsigned char *dst=&convchar[0];
|
||||
int i;
|
||||
if(fat)
|
||||
{
|
||||
for(i=0;i<64;i++)
|
||||
{
|
||||
if((i&7)==0) dst[i>>3] =((src[i]&3)<<0);
|
||||
if((i&7)==2) dst[i>>3]|=((src[i]&3)<<2);
|
||||
if((i&7)==4) dst[i>>3]|=((src[i]&3)<<4);
|
||||
if((i&7)==6) dst[i>>3]|=((src[i]&3)<<6);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for(i=0;i<64;i++)
|
||||
{
|
||||
if((i&3)==0) dst[i>>2] =((src[i]&3)<<0);
|
||||
if((i&3)==1) dst[i>>2]|=((src[i]&3)<<2);
|
||||
if((i&3)==2) dst[i>>2]|=((src[i]&3)<<4);
|
||||
if((i&3)==3) dst[i>>2]|=((src[i]&3)<<6);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void convcharto4bit(int chr)
|
||||
{
|
||||
unsigned char *src=&chars[chr*64];
|
||||
unsigned char *dst=&convchar[0];
|
||||
int i;
|
||||
if(fat)
|
||||
{
|
||||
for(i=0;i<64;i++)
|
||||
{
|
||||
if((i&3)==0) dst[i>>2] =((src[i]&15)<<0);
|
||||
if((i&3)==2) dst[i>>2]|=((src[i]&15)<<4);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for(i=0;i<64;i++)
|
||||
{
|
||||
if((i&1)==0) dst[i>>1] =((src[i]&15)<<0);
|
||||
if((i&1)==1) dst[i>>1]|=((src[i]&15)<<4);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void convcharto8bit(int chr)
|
||||
{
|
||||
unsigned char *src=&chars[chr*64];
|
||||
unsigned char *dst=&convchar[0];
|
||||
int i;
|
||||
for(i=0;i<64;i++)
|
||||
{
|
||||
dst[i]=src[i];
|
||||
}
|
||||
}
|
||||
|
||||
void getcharacter(int x,int y)
|
||||
{
|
||||
int xx,yy,i,j;
|
||||
currentattr=0;
|
||||
for(yy=0;yy<8;yy++)
|
||||
{
|
||||
for(xx=0;xx<8;xx++)
|
||||
{
|
||||
charcell[yy*8+xx]=screen[(((y*8)+yy)*scrwidth)+((x*8)+xx)];
|
||||
if(charcell[yy*8+xx]&paland)
|
||||
{
|
||||
currentattr=( ( charcell[yy*8+xx] & paland ) >> palshift );
|
||||
}
|
||||
charcell[yy*8+xx]&=charand;
|
||||
}
|
||||
}
|
||||
|
||||
if(repeatable)
|
||||
{
|
||||
j=0;
|
||||
for(i=0;i<charnum;i++)
|
||||
{
|
||||
j=1;
|
||||
currentattr=(currentattr&0x3c00)+i;
|
||||
for(xx=0;xx<64;xx++)
|
||||
{
|
||||
if(chars[(i*64)+xx]!=charcell[xx]) {xx=64;j=0;}
|
||||
}
|
||||
if(flipable)
|
||||
{
|
||||
if(j==0)
|
||||
{
|
||||
j=1;
|
||||
currentattr=(currentattr&0x3fff)|0x8000;
|
||||
for(yy=0;yy<8;yy++)
|
||||
{
|
||||
for(xx=0;xx<8;xx++)
|
||||
{
|
||||
if(chars[(i*64)+(yy*8)+xx]!=charcell[(yy*8)+(7-xx)]) {xx=8;yy=8;j=0;}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(j==0)
|
||||
{
|
||||
j=1;
|
||||
currentattr=(currentattr&0x3fff)|0x4000;
|
||||
for(yy=0;yy<8;yy++)
|
||||
{
|
||||
for(xx=0;xx<8;xx++)
|
||||
{
|
||||
if(chars[(i*64)+(yy*8)+xx]!=charcell[((7-yy)*8)+xx]) {xx=8;yy=8;j=0;}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(j==0)
|
||||
{
|
||||
j=1;
|
||||
currentattr=(currentattr&0x3fff)|0xc000;
|
||||
for(yy=0;yy<8;yy++)
|
||||
{
|
||||
for(xx=0;xx<8;xx++)
|
||||
{
|
||||
if(chars[(i*64)+(yy*8)+xx]!=charcell[((7-yy)*8)+(7-xx)]) {xx=8;yy=8;j=0;}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(j==1)
|
||||
{
|
||||
i=charnum;
|
||||
}
|
||||
}
|
||||
if(j==0)
|
||||
{
|
||||
currentattr=(currentattr&0x3c00)+charnum;
|
||||
for(i=0;i<64;i++) chars[(charnum*64)+i]=charcell[i];
|
||||
charnum++;
|
||||
}
|
||||
// charmap[(y*(scrwidth>>3))+x]=currentattr;
|
||||
}
|
||||
else
|
||||
{
|
||||
for(i=0;i<64;i++) chars[(charnum*64)+i]=charcell[i];
|
||||
currentattr=(currentattr&0x3c00)+charnum;
|
||||
charnum++;
|
||||
}
|
||||
}
|
||||
|
||||
void get4x8character(int x,int y)
|
||||
{
|
||||
int xx,yy,i,j;
|
||||
currentattr=0;
|
||||
for(yy=0;yy<8;yy++)
|
||||
{
|
||||
for(xx=0;xx<4;xx++)
|
||||
{
|
||||
charcell[yy*8+xx]=proppal[screen[(((y*8)+yy)*scrwidth)+((x*4)+xx)]];
|
||||
if(charcell[yy*8+xx]&paland)
|
||||
{
|
||||
currentattr=( ( charcell[yy*8+xx] & paland ) >> palshift );
|
||||
}
|
||||
charcell[yy*8+xx]&=charand;
|
||||
charcell[yy*8+xx+4]=0;
|
||||
}
|
||||
}
|
||||
|
||||
if(repeatable)
|
||||
{
|
||||
j=0;
|
||||
for(i=0;i<charnum;i++)
|
||||
{
|
||||
j=1;
|
||||
currentattr=(currentattr&0x3c00)+i;
|
||||
for(xx=0;xx<64;xx++)
|
||||
{
|
||||
if(chars[(i*64)+xx]!=charcell[xx]) {xx=64;j=0;}
|
||||
}
|
||||
if(j==1)
|
||||
{
|
||||
i=charnum;
|
||||
}
|
||||
}
|
||||
if(j==0)
|
||||
{
|
||||
currentattr=(currentattr&0x3c00)+charnum;
|
||||
for(i=0;i<64;i++) chars[(charnum*64)+i]=charcell[i];
|
||||
charnum++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for(i=0;i<64;i++) chars[(charnum*64)+i]=charcell[i];
|
||||
currentattr=(currentattr&0x3c00)+charnum;
|
||||
charnum++;
|
||||
}
|
||||
}
|
||||
|
||||
void getblock(int x,int y)
|
||||
{
|
||||
int i,j,xx,yy;
|
||||
for(yy=0;yy<blockmapsize;yy++)
|
||||
{
|
||||
for(xx=0;xx<blockmapsize;xx++)
|
||||
{
|
||||
getcharacter(x*blockmapsize+xx,y*blockmapsize+yy);
|
||||
blockcell[yy*blockmapsize+xx]=currentattr;
|
||||
}
|
||||
}
|
||||
currentblock=blocknum;
|
||||
for(i=0;i<blocknum;i++)
|
||||
{
|
||||
j=1;
|
||||
for(xx=0;xx<blocksize;xx++)
|
||||
{
|
||||
if(blocks[i*blocksize+xx]!=blockcell[xx])
|
||||
j=0;
|
||||
}
|
||||
if(j==1)
|
||||
{
|
||||
currentblock=i;
|
||||
i=blocknum;
|
||||
}
|
||||
}
|
||||
if(currentblock==blocknum)
|
||||
{
|
||||
for(xx=0;xx<blocksize;xx++)
|
||||
{
|
||||
blocks[blocknum*blocksize+xx]=blockcell[xx];
|
||||
}
|
||||
blocknum++;
|
||||
}
|
||||
blockmap[y*(scrwidth/(blockmapsize*8))+x]=currentblock;
|
||||
}
|
||||
|
||||
int jcmp(char *s1,char *s2)
|
||||
{
|
||||
while(*s1 && *s2)
|
||||
{
|
||||
if(*s1 != *s2) return 0;
|
||||
s1++;
|
||||
s2++;
|
||||
}
|
||||
if(*s1==0 && *s2==0) return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void getcharfile(char *file)
|
||||
{
|
||||
unsigned char buf[64];
|
||||
unsigned char pix;
|
||||
int i,x,y;
|
||||
FILE *f;
|
||||
unsigned int div;
|
||||
unsigned int len;
|
||||
unsigned int xwidth;
|
||||
printf("Opening File '%s'\n",file);
|
||||
f=fopen(file,"rb");
|
||||
if(f==NULL) {printf("Can't open '%s'\n",file);return;}
|
||||
fseek(f,0,SEEK_END);
|
||||
len=ftell(f);
|
||||
fseek(f,0,SEEK_SET);
|
||||
div=0;
|
||||
if(mode==charmap2) {div=8;}
|
||||
if(mode==charmap4) {div=16;}
|
||||
if(mode==charmap16) {div=32;}
|
||||
if(mode==charmap256) {div=64;}
|
||||
if(mode==VGAchars4x8) {div=64;}
|
||||
if(fat) div=div/2;
|
||||
xwidth=8;
|
||||
if(fat) xwidth=4;
|
||||
if(div==0) {fclose(f);return;}
|
||||
printf("Reading %d Chars\n",len/div);
|
||||
charnum=len/div;
|
||||
for(i=0;i<charnum;i++)
|
||||
{
|
||||
fread(buf,1,div,f);
|
||||
for(y=0;y<8;y++)
|
||||
{
|
||||
for(x=0;x<xwidth;x++)
|
||||
{
|
||||
if(mode==charmap2)
|
||||
{
|
||||
pix=(buf[y]>>(7-x))&1;
|
||||
}
|
||||
if(mode==charmap4)
|
||||
{
|
||||
if(fat)
|
||||
pix=(buf[y]>>(6-((x&3)*2)))&3;
|
||||
else
|
||||
pix=(buf[y*2+1-(x>>2)]>>(6-((x&3)*2)))&3;
|
||||
}
|
||||
if(mode==charmap16)
|
||||
{
|
||||
if(fat)
|
||||
pix=(buf[y*2+1-(x>>1)]>>(4-((x&1)*4)))&15;
|
||||
else
|
||||
pix=(buf[y*4+3-(x>>1)]>>(4-((x&1)*4)))&15;
|
||||
}
|
||||
if(mode==charmap256)
|
||||
{
|
||||
pix=buf[y*8+x];
|
||||
}
|
||||
if(mode==VGAchars4x8)
|
||||
{
|
||||
pix=buf[y*4+x];
|
||||
}
|
||||
chars[i*64+y*8+7-x]=pix;
|
||||
}
|
||||
if(fat)
|
||||
{
|
||||
chars[i*64+y*8+0]=chars[i*64+y*8+4];
|
||||
chars[i*64+y*8+1]=chars[i*64+y*8+4];
|
||||
chars[i*64+y*8+2]=chars[i*64+y*8+5];
|
||||
chars[i*64+y*8+3]=chars[i*64+y*8+5];
|
||||
chars[i*64+y*8+4]=chars[i*64+y*8+6];
|
||||
chars[i*64+y*8+5]=chars[i*64+y*8+6];
|
||||
chars[i*64+y*8+6]=chars[i*64+y*8+7];
|
||||
chars[i*64+y*8+7]=chars[i*64+y*8+7];
|
||||
}
|
||||
}
|
||||
}
|
||||
fclose(f);
|
||||
}
|
||||
int main(int c,char **s)
|
||||
{
|
||||
unsigned char palbuf[256*4];
|
||||
int i,j,x,y,w,h,xx,yy;
|
||||
int bytesize,byteand,byteshift,byteout;
|
||||
FILE *f;
|
||||
int getcharfileindex=0;
|
||||
|
||||
doingvga=0;
|
||||
justcharmap=0;
|
||||
blocknum=0;
|
||||
charnum=0;
|
||||
blocksize=1;
|
||||
blockmapsize=1;
|
||||
charnum=0;
|
||||
blocknum=0;
|
||||
yfirst=0;
|
||||
fat=0;
|
||||
|
||||
if(c<2)
|
||||
{
|
||||
printf("bmp8toLite.exe (C) 2009 Jim Bagley\n");
|
||||
printf("usage :-\n");
|
||||
printf("bmp8toLite.exe Filename <-options>\n");
|
||||
printf("Filename is without the '.bmp' extension\n");
|
||||
printf("-vga use VGA colours for the palette\n");
|
||||
printf("-c64s Grab C64 sprites, C64 sprites are 24x21, it will grab the size of the bmp\n");
|
||||
printf(" C64 sprites can be either fat pixel(4colour) or fine pixel(2colour)\n");
|
||||
printf("-c64bitmap2 Grab a C64 2 colour mode bitmap image\n");
|
||||
printf("-c64bitmap4 Grab a C64 4 colour mode bitmap image ( fat pixels )\n");
|
||||
printf("-amsbitmap4 Grab Amstrad 4 colour bitmap mode ( fine pixels )\n");
|
||||
printf("-amsbitmap16 Grab Amstrad 16 colour bitmap mode ( fat pixels )\n");
|
||||
printf("-bitmap2 Grab screen as 1bit ( 2 colour with attributes ) bitmap\n");
|
||||
printf("-bitmap4 Grab screen as 2bit ( 4 colour with attributes ) bitmap\n");
|
||||
printf("-bitmap16 Grab screen as 4bit ( 16 colour with attributes ) bitmap\n");
|
||||
printf("-bitmap256 Grab screen as 8bit ( 256 colour ) bitmap\n");
|
||||
printf("-charmap2 Grab screen as 1bit ( 2 colour with attributes ) character map\n");
|
||||
printf("-charmap4 Grab screen as 2bit ( 4 colour with attributes ) character map\n");
|
||||
printf("-charmap16 Grab screen as 4bit ( 16 colour with attributes ) character map\n");
|
||||
printf("-charmap256 Grab screen as 8bit ( 256 colour ) character map\n");
|
||||
printf("-c64charmap4 Grab screen as 2bit fat pixel ( 4 colour with attributes ) character map\n");
|
||||
printf("-amscharmap16 Grab screen as 4bit fat pixel ( 16 colour with attributes ) character map\n");
|
||||
printf("-invx Invert X pixel order per byte\n");
|
||||
// printf("-flip Turns on Character repeat check and flip checking for X and Y flippable characters\n");
|
||||
printf("-rpt Turns on Character repeat check, for maps, ie doesn't store same character twice.\n");
|
||||
printf("-repeat same as -rpt.\n");
|
||||
printf("-repeatable same as -rpt.\n");
|
||||
printf("-1x1 Sets blocks to 1x1 (8x8 pixels) for charmap grabbing.\n");
|
||||
printf("-2x2 Sets blocks to 2x2 (16x16 pixels) for charmap grabbing.\n");
|
||||
printf("-4x4 Sets blocks to 4x4 (32x32 pixels) for charmap grabbing.\n");
|
||||
printf("-8x8 Sets blocks to 8x8 (64x64 pixels) for charmap grabbing.\n");
|
||||
printf("-yfirst Sets Y grab first for map layout\n");
|
||||
printf("-xfirst Sets X grab first for map layout (default)\n");
|
||||
printf("-invx inverts the pixel order in a byte for spectrum and fast spectrum\n");
|
||||
printf("-nopal Don't save palette in 8bit mode, use real colour values\n");
|
||||
printf("-2600 Grab a 2600 style background\n");
|
||||
printf("-using grab chars from screen, but using a file as a base font\n");
|
||||
}
|
||||
|
||||
while(c>2)
|
||||
{
|
||||
if(jcmp(s[c-1],"-vga")) {doingvga=1;c--;}
|
||||
else if(jcmp(s[c-1],"-c64s")) {mode=C64sprites;ext=extjcs;charand=1;paland=0xfe;palshift=1;c--;}
|
||||
else if(jcmp(s[c-1],"-c64bitmap2")) {mode=C64bitmap2;ext=extcb2;charand=1;paland=0xfe;palshift=1;c--;}
|
||||
else if(jcmp(s[c-1],"-c64bitmap4")) {mode=C64bitmap4;ext=extcb4;charand=3;paland=0xfc;palshift=2;c--;}
|
||||
else if(jcmp(s[c-1],"-amsbitmap4")) {mode=AMSbitmap4;ext=extab4;charand=3;paland=0xfc;palshift=2;c--;}
|
||||
else if(jcmp(s[c-1],"-amsbitmap16")) {mode=AMSbitmap16;ext=exta16;charand=15;paland=0xf0;palshift=4;c--;}
|
||||
else if(jcmp(s[c-1],"-bitmap2")) {mode=bitmap2;ext=extbm2;charand=1;paland=0xfe;palshift=1;c--;}
|
||||
else if(jcmp(s[c-1],"-bitmap4")) {mode=bitmap4;ext=extbm4;charand=3;paland=0xfc;palshift=2;c--;}
|
||||
else if(jcmp(s[c-1],"-bitmap16")) {mode=bitmap16;ext=extb16;charand=15;paland=0xfe;palshift=4;c--;}
|
||||
else if(jcmp(s[c-1],"-bitmap256")) {mode=bitmap256;ext=extb8b;charand=255;paland=0;palshift=0;c--;}
|
||||
else if(jcmp(s[c-1],"-charmap2")) {mode=charmap2;ext=extjb2;charand=1;paland=0xfe;palshift=1;c--;}
|
||||
else if(jcmp(s[c-1],"-charmap4")) {mode=charmap4;ext=extjb4;charand=3;paland=0xfc;palshift=2;c--;}
|
||||
else if(jcmp(s[c-1],"-charmap16")) {mode=charmap16;ext=extj16;charand=15;paland=0xf0;palshift=4;c--;}
|
||||
else if(jcmp(s[c-1],"-charmap256")) {mode=charmap256;ext=extj8b;charand=255;paland=0;palshift=0;c--;}
|
||||
else if(jcmp(s[c-1],"-vga4x8")) {mode=VGAchars4x8;ext=extj8b;charand=255;paland=0;palshift=0;c--;fat=1;doingvga=1;repeatable=1;nopalette=1;justcharmap=1;blockmapsize=1;blocksize=1;}
|
||||
else if(jcmp(s[c-1],"-c64charmap4")) {mode=charmap4;ext=extjb4;charand=3;paland=0xfc;palshift=2;c--;fat=1;}
|
||||
else if(jcmp(s[c-1],"-amscharmap16")){mode=charmap16;ext=extj16;charand=15;paland=0xf0;palshift=4;c--;fat=1;}
|
||||
else if(jcmp(s[c-1],"-flip")) {repeatable=1;flipable=1;c--;}
|
||||
else if(jcmp(s[c-1],"-flipable")) {repeatable=1;flipable=1;c--;}
|
||||
else if(jcmp(s[c-1],"-norpt")) {repeatable=0;c--;}
|
||||
else if(jcmp(s[c-1],"-norepeat")) {repeatable=0;c--;}
|
||||
else if(jcmp(s[c-1],"-notrepeatable")) {repeatable=0;c--;}
|
||||
else if(jcmp(s[c-1],"-rpt")) {repeatable=1;c--;}
|
||||
else if(jcmp(s[c-1],"-repeat")) {repeatable=1;c--;}
|
||||
else if(jcmp(s[c-1],"-repeatable")) {repeatable=1;c--;}
|
||||
else if(jcmp(s[c-1],"-1x1")) {justcharmap=1;blockmapsize=1;blocksize=1;c--;}
|
||||
else if(jcmp(s[c-1],"-2x2")) {justcharmap=0;blockmapsize=2;blocksize=4;c--;}
|
||||
else if(jcmp(s[c-1],"-4x4")) {justcharmap=0;blockmapsize=4;blocksize=16;c--;}
|
||||
else if(jcmp(s[c-1],"-8x8")) {justcharmap=0;blockmapsize=8;blocksize=64;c--;}
|
||||
else if(jcmp(s[c-1],"-yfirst")) {yfirst=1;c--;}
|
||||
else if(jcmp(s[c-1],"-xfirst")) {yfirst=0;c--;}
|
||||
else if(jcmp(s[c-1],"-invx")) {invx=(1-invx)&1;c--;}
|
||||
else if(jcmp(s[c-1],"-nopal")) {nopalette=1;c--;}
|
||||
else if(jcmp(s[c-1],"-pal16")) {pal16=1;c--;}
|
||||
else if(jcmp(s[c-1],"-2600")) {getting_2600=1;c--;}
|
||||
else if(jcmp(s[c-2],"-using")) {getcharfileindex=c-1;c-=2;}
|
||||
else if(jcmp(s[c-2],"-fat")) {fat=1;}
|
||||
else {printf("Unknown option '%s'\n",s[c-1]);exit(1);}
|
||||
}
|
||||
if(c!=2)
|
||||
{
|
||||
printf("exename filename\n");
|
||||
exit(0);
|
||||
}
|
||||
if(getcharfileindex)
|
||||
{
|
||||
getcharfile(s[getcharfileindex]);
|
||||
}
|
||||
setuppropcolours();
|
||||
|
||||
sprintf(fname,"%s.bmp",s[1]);
|
||||
f=fopen(fname,"rb");
|
||||
if(f!=NULL)
|
||||
{
|
||||
fread(header,0x36,1,f);
|
||||
scrwidth=header[9];
|
||||
scrheight=header[11];
|
||||
printf("w=%d\nh=%d\n",scrwidth,scrheight);
|
||||
fread(palbuf,256,4,f);
|
||||
for(i=0;i<256;i++)
|
||||
{
|
||||
proppal[i]=getpixelcolour(palbuf[i*4+0],palbuf[i*4+1],palbuf[i*4+2]);
|
||||
}
|
||||
|
||||
fseek(f,header[5],SEEK_SET);
|
||||
for(i=0;i<scrheight;i++)
|
||||
{
|
||||
fread(&screen[((scrheight-1)-i)*scrwidth],scrwidth,1,f);
|
||||
}
|
||||
fclose(f);
|
||||
|
||||
if(getting_2600)
|
||||
{
|
||||
sprintf(fname,"%s.VCS",s[1]);
|
||||
f=fopen(fname,"wb");
|
||||
if(f!=NULL)
|
||||
{
|
||||
int xstp=scrwidth/40;
|
||||
int border=0;
|
||||
for(y=0;y<scrheight;y++)
|
||||
{
|
||||
int background=screen[y*scrwidth];
|
||||
int foreground=0;
|
||||
byteout=0;
|
||||
for(xx=x=0;x<scrwidth;x+=xstp,xx++)
|
||||
{
|
||||
byteout<<=1;
|
||||
if(screen[y*scrwidth+x]!=background) {byteout+=1;foreground=screen[y*scrwidth+x];}
|
||||
if((xx&7)==7)
|
||||
fwrite(&byteout,1,1,f);
|
||||
}
|
||||
if(palbuf[background*4+0]==255 && palbuf[background*4+1]==0 && palbuf[background*4+2]==255)
|
||||
{
|
||||
background=0;
|
||||
fwrite(&background,1,1,f);
|
||||
fwrite(&background,1,1,f);
|
||||
fwrite(&proppal[border],1,1,f);
|
||||
}
|
||||
else
|
||||
{
|
||||
fwrite(&proppal[background],1,1,f);
|
||||
fwrite(&proppal[foreground],1,1,f);
|
||||
fwrite(&proppal[border],1,1,f);
|
||||
}
|
||||
}
|
||||
fclose(f);
|
||||
}
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if(justcharmap==0)
|
||||
{
|
||||
for(y=0;y<(scrheight/(blockmapsize*8));y++)
|
||||
{
|
||||
for(x=0;x<(scrwidth/(blockmapsize*8));x++)
|
||||
{
|
||||
getblock(x,y);
|
||||
}
|
||||
}
|
||||
printf("block map size = ( %d,%d )\nBlocks Used = %d\nChars Used = %d\n",scrwidth/(blockmapsize*8),scrheight/(blockmapsize*8),blocknum,charnum);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(mode==VGAchars4x8)
|
||||
{
|
||||
for(y=0;y<(scrheight/8);y++)
|
||||
{
|
||||
for(x=0;x<(scrwidth/4);x++)
|
||||
{
|
||||
get4x8character(x,y);
|
||||
charmap[(y*(scrwidth/4))+x]=currentattr;
|
||||
// printf("%02x,",currentattr);
|
||||
}
|
||||
// printf("\n");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for(y=0;y<(scrheight/8);y++)
|
||||
{
|
||||
for(x=0;x<(scrwidth/8);x++)
|
||||
{
|
||||
getcharacter(x,y);
|
||||
charmap[(y*(scrwidth/8))+x]=currentattr;
|
||||
// printf("%02x,",currentattr);
|
||||
}
|
||||
// printf("\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
if( mode>=charmap2 && mode<=charmap256 )
|
||||
printf("Char map size = ( %d,%d )\nChars Used = %d\n",scrwidth/8,scrheight/8,charnum);
|
||||
if( mode==VGAchars4x8 )
|
||||
printf("Char map size = ( %d,%d )\nChars Used = %d\n",scrwidth/4,scrheight/8,charnum);
|
||||
|
||||
if(nopalette==0)
|
||||
{
|
||||
sprintf(fname,"%s.pal",s[1]);
|
||||
f=fopen(fname,"wb");
|
||||
if(f!=NULL)
|
||||
{
|
||||
if(pal16)
|
||||
fwrite(proppal,16,1,f);
|
||||
else
|
||||
fwrite(proppal,256,1,f);
|
||||
fclose(f);
|
||||
}
|
||||
}
|
||||
|
||||
if(mode!=C64sprites && repeatable!=0)
|
||||
{
|
||||
if(justcharmap)
|
||||
{
|
||||
sprintf(fname,"%s.map",s[1]);
|
||||
f=fopen(fname,"wb");
|
||||
if(f!=NULL)
|
||||
{
|
||||
if(mode==VGAchars4x8)
|
||||
{
|
||||
if(yfirst==0)
|
||||
{
|
||||
fwrite(charmap,scrheight/8,(scrwidth/4)*2,f);
|
||||
}
|
||||
else
|
||||
{
|
||||
for(x=0;x<(scrwidth/(blockmapsize*4));x++)
|
||||
{
|
||||
for(y=0;y<(scrheight/(blockmapsize*8));y++)
|
||||
{
|
||||
fwrite(&charmap[y*(scrwidth/(blockmapsize*4))+x],1,2,f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(yfirst==0)
|
||||
{
|
||||
fwrite(charmap,scrheight/8,(scrwidth/8)*2,f);
|
||||
}
|
||||
else
|
||||
{
|
||||
for(x=0;x<(scrwidth/(blockmapsize*8));x++)
|
||||
{
|
||||
for(y=0;y<(scrheight/(blockmapsize*8));y++)
|
||||
{
|
||||
fwrite(&charmap[y*(scrwidth/(blockmapsize*8))+x],1,2,f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
fclose(f);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf(fname,"%s.mpb",s[1]);
|
||||
f=fopen(fname,"wb");
|
||||
if(f!=NULL)
|
||||
{
|
||||
if(yfirst==0)
|
||||
{
|
||||
fwrite(blockmap,scrheight/(blockmapsize*8),(scrwidth/(blockmapsize*8))*2,f);
|
||||
}
|
||||
else
|
||||
{
|
||||
for(x=0;x<(scrwidth/(blockmapsize*8));x++)
|
||||
{
|
||||
for(y=0;y<(scrheight/(blockmapsize*8));y++)
|
||||
{
|
||||
fwrite(&blockmap[y*(scrwidth/(blockmapsize*8))+x],1,2,f);
|
||||
}
|
||||
}
|
||||
}
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
sprintf(fname,"%s.blx",s[1]);
|
||||
f=fopen(fname,"wb");
|
||||
if(f!=NULL)
|
||||
{
|
||||
fwrite(blocks,blocknum,blocksize*2,f);
|
||||
fclose(f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// sprintf(fname,"%s.%s",s[1],ext);
|
||||
if( (mode>=charmap2 && mode<=charmap256 ) || mode==VGAchars4x8)
|
||||
{
|
||||
sprintf(fname,"%s.chr",s[1]);
|
||||
}
|
||||
else if(mode==C64sprites)
|
||||
{
|
||||
sprintf(fname,"%s.JCS",s[1]);
|
||||
}
|
||||
else if( (mode>=bitmap2 && mode<=AMSbitmap16 ) )
|
||||
{
|
||||
sprintf(fname,"%s.bit",s[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Don't know Graphics mode :(\n");
|
||||
return 0;
|
||||
}
|
||||
f=fopen(fname,"wb");
|
||||
if(f!=NULL)
|
||||
{
|
||||
if( (mode>=charmap2 && mode<=charmap256) || mode==VGAchars4x8 )
|
||||
{
|
||||
for(i=0;i<charnum;i++)
|
||||
{
|
||||
if(mode==charmap2) {convcharto1bit(i);fwrite(convchar,1,fat?4:8,f);}
|
||||
if(mode==charmap4) {convcharto2bit(i);fwrite(convchar,2,fat?4:8,f);}
|
||||
if(mode==charmap16) {convcharto4bit(i);fwrite(convchar,4,fat?4:8,f);}
|
||||
if(mode==charmap256) {convcharto8bit(i);fwrite(convchar,8,fat?4:8,f);}
|
||||
if(mode==VGAchars4x8)
|
||||
{
|
||||
convcharto8bit(i);
|
||||
for(y=0;y<8;y++)
|
||||
for(x=0;x<4;x++)
|
||||
fwrite(&convchar[y*8+x],1,1,f);
|
||||
}
|
||||
}
|
||||
}
|
||||
if( (mode>=bitmap2 && mode<=AMSbitmap16 ) )
|
||||
{
|
||||
if(mode==C64bitmap2) {bytesize=8;byteand= 1;byteshift=1;fat=0;}
|
||||
if(mode==C64bitmap4) {bytesize=4;byteand= 3;byteshift=2;fat=1;}
|
||||
if(mode==AMSbitmap4) {bytesize=4;byteand= 3;byteshift=2;fat=0;}
|
||||
if(mode==AMSbitmap16){bytesize=2;byteand= 15;byteshift=4;fat=1;}
|
||||
if(mode==bitmap2) {bytesize=8;byteand= 1;byteshift=1;fat=0;}
|
||||
if(mode==bitmap4) {bytesize=4;byteand= 3;byteshift=2;fat=0;}
|
||||
if(mode==bitmap16) {bytesize=2;byteand= 15;byteshift=4;fat=0;}
|
||||
if(mode==bitmap256) {bytesize=1;byteand=255;byteshift=0;fat=0;}
|
||||
for(y=0;y<scrheight;y++)
|
||||
{
|
||||
for(x=0;x<scrwidth/(bytesize*(1+fat));x++)
|
||||
{
|
||||
byteout=0;
|
||||
for(xx=0;xx<bytesize;xx++)
|
||||
{
|
||||
if(invx)
|
||||
{
|
||||
byteout+=(screen[(y*scrwidth)+(((x*bytesize)+xx)*(1+fat))]&byteand)<<(xx*byteshift);
|
||||
}
|
||||
else
|
||||
{
|
||||
byteout+=(screen[(y*scrwidth)+(((x*bytesize)+xx)*(1+fat))]&byteand)<<(((bytesize-1)-xx)*byteshift);
|
||||
}
|
||||
}
|
||||
if(nopalette) byteout=proppal[byteout];
|
||||
fwrite(&byteout,1,1,f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(mode==C64sprites)
|
||||
{
|
||||
for(y=0;y<scrheight;y+=21)
|
||||
{
|
||||
for(x=0;x<scrwidth;x+=24)
|
||||
{
|
||||
byteand=1;byteshift=1;
|
||||
j=0;
|
||||
for(yy=0;yy<21;yy++)
|
||||
{
|
||||
for(xx=0;xx<24;xx++)
|
||||
{
|
||||
if((screen[((y+yy)*scrwidth)+(x+xx)]&3)>1)
|
||||
{
|
||||
byteand=3;byteshift=2;
|
||||
j=1;
|
||||
xx=24;yy=21;
|
||||
}
|
||||
}
|
||||
}
|
||||
for(yy=0;yy<21;yy++)
|
||||
{
|
||||
for(xx=0;xx<24;xx+=byteshift)
|
||||
{
|
||||
if((xx&7)==0) byteout=0;
|
||||
byteout+=((screen[((y+yy)*scrwidth)+(x+xx)]&byteand)<<((8-byteshift)-(xx&7)));
|
||||
if((xx&7)==(8-(byteshift)))
|
||||
{
|
||||
fwrite(&byteout,1,1,f);
|
||||
}
|
||||
}
|
||||
}
|
||||
byteout=0;
|
||||
fwrite(&byteout,1,1,f); // to keep nice round 64bytes per sprite :)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fclose(f);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Error Creating '%s'\n",fname);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Error Opening '%s'\n",fname);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
Binary file not shown.
Binary file not shown.
After Width: | Height: | Size: 3.3 KiB |
Binary file not shown.
Binary file not shown.
Binary file not shown.
After Width: | Height: | Size: 61 KiB |
File diff suppressed because one or more lines are too long
Binary file not shown.
Binary file not shown.
After Width: | Height: | Size: 61 KiB |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,178 @@
|
|||
DAT
|
||||
{
|
||||
video-treiber-frame
|
||||
- basiert auf dem tollen tutorial von bamse
|
||||
|
||||
30-09-2009-dr235 driver 1 - originalcode, anpassung an hive
|
||||
driver 2 - senkrechte balken
|
||||
driver 3 - einfarbige fläche
|
||||
driver 4 - wandernde farbbalken, 1 byte pro pixel :)
|
||||
driver 5 -
|
||||
|
||||
|
||||
}
|
||||
|
||||
CON
|
||||
_CLKMODE = xtal1 + pll16x
|
||||
_XINFREQ = 5_000_000
|
||||
|
||||
PUB start
|
||||
|
||||
cognew(@entry,0) ' neue cog mit video-treiber starten
|
||||
|
||||
DAT org 0
|
||||
entry jmp #Start_of_driver ' Start here...
|
||||
|
||||
' NTSC sync stuff.
|
||||
NTSC_color_freq long 3_579_545 ' NTSC Color Frequency
|
||||
NTSC_hsync_VSCL long 39 << 12 + 624 ' Used for the Horisontal Sync
|
||||
NTSC_active_VSCL long 188 << 12 + 3008 ' Used for the Vertical sync
|
||||
NTSC_hsync_pixels long %%11_0000_1_2222222_11 ' Horizontal sync pixels
|
||||
NTSC_vsync_high_1 long %%1111111_2222222_11 ' Vertical sync signal part one for lines 1-6 and 13 to 18
|
||||
NTSC_vsync_high_2 long %%1111111111111111 ' Vertical sync signal part two for lines 1-6 and 13 to 18
|
||||
NTSC_vsync_low_1 long %%2222222222222222 ' Vertical sync signal part one for lines 7-12
|
||||
NTSC_vsync_low_2 long %%22_1111111_2222222 ' Vertical sync signal part two for lines 7-12
|
||||
NTSC_sync_signal_palette long $00_00_02_8A ' The sync Palette
|
||||
|
||||
' hbeat --------+ +------------------------- /cs
|
||||
' clk -------+| |
|
||||
' /wr ------+|| | +---------------------- videopins
|
||||
' /hs -----+||| | |
|
||||
' |||| |--+ -------- d0..d7
|
||||
tvport_mask long %00000000_01110000_00000000_00000000 ' Maske für Video-Pins am Hive
|
||||
vsu_cfg long %01110100_00000000_00000100_01110000 ' Wert für VCFG-Register
|
||||
|
||||
NTSC_Graphic_Lines long 244 ' Anzahl der sichtbaren Zeilen
|
||||
NTSC_Graphics_Pixels_VSCL long 16 << 12 + 16 ' 16 clocks per pixel, 64 clocks per frame.
|
||||
|
||||
|
||||
PAL0 long $01
|
||||
PAL1 long $0E
|
||||
PAL2 long $0D
|
||||
PAL3 long $0C
|
||||
PAL4 long $0B
|
||||
DIF1 long $00_10
|
||||
CNT_ANIM long $4
|
||||
|
||||
' Loop counters.
|
||||
line_loop long $0 ' Line counter...
|
||||
pix_loop long $0
|
||||
anim_loop long $0
|
||||
|
||||
' General Purpose Registers
|
||||
r0 long $0 ' Initialize to 0
|
||||
r1 long $0
|
||||
r2 long $0
|
||||
r3 long $0
|
||||
c1 long $0 ' colorregister
|
||||
c2 long $0
|
||||
c3 long $0
|
||||
|
||||
'========================== Start of the actual driver =============================================
|
||||
|
||||
Start_of_driver
|
||||
' VCFG, setup Video Configuration register and 3-bit tv DAC pins to output
|
||||
mov VCFG, vsu_cfg ' Konfiguration der VSU
|
||||
or DIRA, tvport_mask ' Set DAC pins to output
|
||||
|
||||
' CTRA, setup Frequency to Drive Video
|
||||
movi CTRA,#%00001_111 ' pll internal routed to Video, PHSx+=FRQx (mode 1) + pll(16x)
|
||||
mov r1, NTSC_color_freq ' r1: Color frequency in Hz (3.579_545MHz)
|
||||
rdlong r2, #0 ' Copy system clock from main memory location 0. (80Mhz)
|
||||
' perform r3 = 2^32 * r1 / r2
|
||||
mov r0,#32+1
|
||||
:loop cmpsub r1,r2 wc
|
||||
rcl r3,#1
|
||||
shl r1,#1
|
||||
djnz r0,#:loop
|
||||
mov FRQA, r3 ' Set frequency for counter A
|
||||
|
||||
|
||||
'========================== Start of Frame Loop ==============================================
|
||||
|
||||
frame_loop
|
||||
mov anim_loop, CNT_ANIM
|
||||
frame_loop2
|
||||
|
||||
'========================== Screen =============================================
|
||||
|
||||
mov line_loop, NTSC_Graphic_Lines ' anzahl der zeilen laden (244)
|
||||
|
||||
user_lines
|
||||
'------ zeilensynchronisation
|
||||
mov VSCL, NTSC_hsync_VSCL ' Setup VSCL for horizontal sync.
|
||||
waitvid NTSC_sync_signal_palette, NTSC_hsync_pixels ' Generate sync.
|
||||
|
||||
|
||||
'------ sichtbarer zeileninhalt
|
||||
mov VSCL, NTSC_Graphics_Pixels_VSCL ' Setup VSCL for user pixels.
|
||||
|
||||
'------ verschiedenfarbige balken ausgeben
|
||||
mov c1, PAL4
|
||||
add c1, c3
|
||||
mov pix_loop, #23
|
||||
bar_loop
|
||||
add c1, #$10 ' 8 x pixel einzeln! ausgeben
|
||||
mov c2, c1 ' also 2 tiles
|
||||
waitvid c2, #0 ' 8 bit pro pixel!
|
||||
add c2, #1
|
||||
waitvid c2, #0
|
||||
add c2, #1
|
||||
waitvid c2, #0
|
||||
add c2, #1
|
||||
waitvid c2, #0
|
||||
sub c2, #1
|
||||
waitvid c2, #0
|
||||
sub c2, #1
|
||||
waitvid c2, #0
|
||||
sub c2, #1
|
||||
waitvid c2, #0
|
||||
sub c2, #1
|
||||
waitvid c2, #0
|
||||
|
||||
djnz pix_loop, #bar_loop
|
||||
|
||||
sub c2, #1
|
||||
waitvid c2, #0 ' 4 mal extrapixel, für das timing
|
||||
sub c2, #1 ' also insgesamt 188 pixel pro zeile
|
||||
waitvid c2, #0
|
||||
sub c2, #1
|
||||
waitvid c2, #0
|
||||
sub c2, #1
|
||||
waitvid c2, #0
|
||||
|
||||
djnz line_loop, #user_lines ' schleife durch alle zeilen
|
||||
|
||||
'========================== The 16 lines of Horizontal sync ==================================
|
||||
|
||||
mov line_loop, #6 ' Line 244, start of first high sync.
|
||||
vsync_high1 mov VSCL, NTSC_hsync_VSCL
|
||||
waitvid NTSC_sync_signal_palette, NTSC_vsync_high_1
|
||||
mov VSCL, NTSC_active_VSCL
|
||||
waitvid NTSC_sync_signal_palette, NTSC_vsync_high_2
|
||||
djnz line_loop, #vsync_high1
|
||||
|
||||
mov line_loop, #6 ' Line 250, start of the Seration pulses.
|
||||
vsync_low mov VSCL, NTSC_active_VSCL
|
||||
waitvid NTSC_sync_signal_palette, NTSC_vsync_low_1
|
||||
mov VSCL,NTSC_hsync_VSCL
|
||||
waitvid NTSC_sync_signal_palette, NTSC_vsync_low_2
|
||||
djnz line_loop, #vsync_low
|
||||
|
||||
mov line_loop, #6 ' Line 256, start of second high sync.
|
||||
vsync_high2 mov VSCL, NTSC_hsync_VSCL
|
||||
waitvid NTSC_sync_signal_palette, NTSC_vsync_high_1
|
||||
mov VSCL, NTSC_active_VSCL
|
||||
waitvid NTSC_sync_signal_palette, NTSC_vsync_high_2
|
||||
djnz line_loop, #vsync_high2
|
||||
|
||||
'========================== End of Frame Loop =============================================
|
||||
djnz anim_loop, #frame_loop2
|
||||
add c3, #$10
|
||||
|
||||
|
||||
'========================== Animation ==================================
|
||||
|
||||
jmp #frame_loop ' And repeat for ever...
|
||||
FIT
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,72 @@
|
|||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
unsigned int clut[] = {0x22222222, 0x33333333, 0x44444444, 0x55555555, 0x66666666, 0x77777777, 0x1144EE55, 0x11337755, 0x2244EE66, 0x22447755, 0x3355EE66, 0x22335544, 0x33446655, 0x44557766, 0x1133EE66, 0x2233EE77, 0x22337766, 0x3344EE77, 0x22336655, 0x33447766, 0x4455EE77, 0x3333EEEE, 0x33337777, 0x33336666, 0x44447777, 0x33335555, 0x44446666, 0x55557777, 0x33334444, 0x44445555, 0x55556666, 0x66667777, 0x443377EE, 0x44336677, 0x554477EE, 0x553366EE, 0x44335566, 0x55446677, 0x665577EE, 0x55335577, 0x664466EE, 0x44334455, 0x55445566, 0x66556677, 0x663355EE, 0x55334466, 0x66445577, 0x775566EE, 0x773344EE, 0x66334477, 0x774455EE, 0x77333377, 0x66333366, 0x77444477, 0x55333355, 0x66444466, 0x77555577, 0x44333344, 0x55444455, 0x66555566, 0x77666677, 0xEE331166, 0xEE332277, 0x77332266, 0x66332255, 0x77443366, 0xEE330055, 0x77330044, 0xEE441155, 0x77331155, 0xEE442266, 0x66331144, 0x77442255, 0x55332244, 0x66443355, 0x77554466, 0xEE440044, 0x66330033, 0x77441144, 0xEE552255, 0x55331133, 0x66442244, 0x77553355, \
|
||||
0x44332233, 0x55443344, 0x66554455, 0x77665566, 0xEE550033, 0x77440033, 0xEE551144, 0x77551133, 0xEE662244, 0x66441133, 0x77552244, 0x55442233, 0x66553344, 0x77664455, 0xEE660022, 0x77550022, 0xEE661133, 0x77661122, 0x66551122, 0x77662233, 0x55441122, 0x66552233, 0x77663344, 0x66661111, 0x66662222, 0x55552222, 0x66663333, 0x44442222, 0x55553333, 0x66664444, 0x33332222, 0x44443333, 0x55554444, 0x66665555, 0x55662211, 0x44552211, 0x55663322, 0x44662200, 0x44663311, 0x33442211, 0x44553322, 0x55664433, 0x33663300, 0x33553311, 0x44664422, 0x33443322, 0x44554433, 0x55665544, 0x22664400, 0x22553300, 0x33664411, 0x22443311, 0x33554422, 0x44665533, 0x22665511, 0x22554411, 0x33665522, 0x22666622, 0x22555522, 0x33666633, 0x22444422, 0x33555533, 0x44666644, 0x22333322, 0x33444433, 0x44555544, 0x55666655, 0x1166EE33, 0x11667722, 0x22667733, 0x22556633, 0x33667744, 0x1155EE44, 0x11557733, 0x2266EE44, 0x22557744, 0x3366EE55, 0x22445533, 0x33556644, 0x44667755, 0x11447744, 0x2255EE55, 0x22446644, 0x33557755, 0x4466EE66, \
|
||||
0x22334433, 0x33445544, 0x44556655, 0x55667766};
|
||||
int red[] = {-1, 0, 51, 102, 153, 204, 255, 17, 8, 59, 49, 100, 29, 80, 131, 17, 59, 49, 100, 39, 90, 141, 100, 90, 80, 131, 71, 122, 173, 61, 112, 163, 214, 131, 122, 173, 163, 112, 163, 214, 153, 204, 102, 153, 204, 194, 143, 194, 245, 226, 184, 235, 216, 175, 226, 133, 184, 235, 92, 143, 194, 245, 238, 247, 206, 165, 216, 228, 187, 238, 196, 247, 155, 206, 124, 175, 226, 228, 145, 196, 247, 114, 165, 216, 82, 133, 184, 235, 228, 187, 238, 196, 247, 155, 206, 124, 175, 226, 228, 187, 238, 196, 155, 206, 114, 165, 216, 155, 165, 124, 175, 82, 133, 184, 41, 92, 143, 194, 124, 82, 133, 82, 92, 41, 92, 143, 51, 51, 102, 51, 102, 153, 20, 10, 61, 10, 61, 112, 29, 20, 71, 39, 29, 80, 20, 71, 122, 10, 61, 112, 163, 17, 8, 49, 39, 90, 17, 8, 59, 49, 100, 29, 80, 131, 8, 59, 39, 90, 141, 20, 71, 122, 173, -1};
|
||||
int grn[] = {-1, 0, 51, 102, 153, 204, 255, 189, 161, 212, 173, 224, 106, 157, 208, 200, 223, 184, 235, 145, 196, 247, 246, 207, 168, 219, 129, 180, 231, 90, 141, 192, 243, 230, 191, 242, 214, 152, 203, 254, 175, 226, 113, 164, 215, 198, 136, 187, 238, 182, 159, 210, 143, 120, 171, 97, 148, 199, 74, 125, 176, 227, 88, 127, 104, 81, 132, 49, 26, 77, 65, 116, 42, 93, 58, 109, 160, 38, 3, 54, 105, 19, 70, 121, 35, 86, 137, 188, 27, 15, 66, 43, 94, 31, 82, 47, 98, 149, 16, 4, 55, 32, 20, 71, 8, 59, 110, 9, 48, 36, 87, 24, 75, 126, 12, 63, 114, 165, 25, 13, 64, 2, 41, 1, 52, 103, 18, 29, 80, 40, 91, 142, 34, 6, 57, 17, 68, 119, 73, 45, 96, 112, 84, 135, 56, 107, 158, 28, 79, 130, 181, 167, 128, 151, 123, 174, 178, 139, 190, 162, 213, 95, 146, 197, 150, 201, 134, 185, 236, 67, 118, 169, 220, -1};
|
||||
int blu[] = {-1, 0, 51, 102, 153, 204, 255, 99, 46, 97, 99, 150, 48, 99, 150, 43, 41, 43, 94, 46, 97, 148, 38, 41, 43, 94, 46, 97, 148, 48, 99, 150, 201, 38, 41, 92, 38, 43, 94, 145, 41, 92, 46, 97, 148, 38, 43, 94, 145, 38, 41, 92, 41, 43, 94, 46, 97, 148, 48, 99, 150, 201, 43, 41, 43, 46, 97, 46, 48, 99, 46, 97, 48, 99, 48, 99, 150, 102, 51, 102, 153, 51, 102, 153, 51, 102, 153, 204, 158, 105, 156, 158, 209, 105, 156, 105, 156, 207, 214, 161, 212, 214, 161, 212, 107, 158, 209, 217, 214, 161, 212, 107, 158, 209, 54, 105, 156, 207, 217, 163, 214, 219, 217, 110, 161, 212, 219, 163, 214, 107, 158, 209, 219, 166, 217, 110, 161, 212, 217, 163, 214, 214, 161, 212, 107, 158, 209, 54, 105, 156, 207, 212, 214, 212, 158, 209, 156, 158, 209, 156, 207, 105, 156, 207, 102, 153, 102, 153, 204, 51, 102, 153, 204, -1};
|
||||
int num[256];
|
||||
char iline[1024];
|
||||
|
||||
|
||||
void main( void )
|
||||
{
|
||||
int x, y, r, g, b, i, j, m, n;
|
||||
unsigned char *ptr, *dat;
|
||||
|
||||
if ( ( ptr = dat = malloc( 2<<16 ) ) == NULL )
|
||||
return;
|
||||
|
||||
for ( i = 0; i < 256; i++ )
|
||||
num[i] = 0;
|
||||
|
||||
fgets( iline, 1024, stdin );
|
||||
if ( strncmp( iline, "P3", 2 ) )
|
||||
return;
|
||||
fgets( iline, 1024, stdin );
|
||||
fscanf( stdin, "%d %d\n", &x, &y );
|
||||
fgets( iline, 1024, stdin );
|
||||
while( !feof( stdin ) )
|
||||
{
|
||||
fscanf( stdin, "%d %d %d", &r, &g, &b );
|
||||
if ( feof( stdin ) )
|
||||
break;
|
||||
if ( red[0] < 0 )
|
||||
{
|
||||
red[0] = r; grn[0] = g; blu[0] = b;
|
||||
}
|
||||
for ( i = 0; red[i] >=0; i++ )
|
||||
{
|
||||
m = (red[i]-r)*(red[i]-r)+(grn[i]-g)*(grn[i]-g)+(blu[i]-b)*(blu[i]-b);
|
||||
if ( i == 0 || m < n )
|
||||
{
|
||||
j = i; n = m;
|
||||
}
|
||||
}
|
||||
num[j]++;
|
||||
*ptr++ = j;
|
||||
}
|
||||
for ( j = i = 0; i < 256; i++ )
|
||||
{
|
||||
if ( num[i] )
|
||||
{
|
||||
num[i] = j++;
|
||||
if ( i > 0 )
|
||||
fprintf( stdout, "%08X\n", clut[i-1] );
|
||||
}
|
||||
}
|
||||
for ( i = 0; dat < ptr; dat++)
|
||||
if ( ++i == x )
|
||||
{
|
||||
fprintf( stdout, "%2d\n", num[*dat] );
|
||||
i = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf( stdout, "%2d, ", num[*dat] );
|
||||
}
|
||||
fprintf( stdout, "\n" );
|
||||
}
|
Binary file not shown.
|
@ -0,0 +1,2 @@
|
|||
[InternetShortcut]
|
||||
URL=http://forums.parallax.com/forums/default.aspx?f=25&m=343999
|
Binary file not shown.
Binary file not shown.
After Width: | Height: | Size: 19 KiB |
Binary file not shown.
After Width: | Height: | Size: 29 KiB |
Binary file not shown.
After Width: | Height: | Size: 41 KiB |
Binary file not shown.
|
@ -0,0 +1,51 @@
|
|||
{\rtf1\ansi\deff1\adeflang1025
|
||||
{\fonttbl{\f0\froman\fprq2\fcharset128 Liberation Serif{\*\falt Times New Roman};}{\f1\fswiss\fprq0\fcharset0 Arial;}{\f2\fswiss\fprq2\fcharset128 Liberation Sans{\*\falt Arial};}{\f3\fswiss\fprq0\fcharset0 Arial;}{\f4\fnil\fprq2\fcharset128 DejaVu Sans;}}
|
||||
{\colortbl;\red0\green0\blue0;\red128\green128\blue128;}
|
||||
{\stylesheet{\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang1031\loch\f1\fs24\lang1031\snext1 Normal;}
|
||||
{\s2\sb240\sa120\keepn\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs28\lang1081\ltrch\dbch\af4\langfe2052\hich\f2\fs28\lang1031\loch\f2\fs28\lang1031\sbasedon1\snext3 Heading;}
|
||||
{\s3\sa120\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang1031\loch\f1\fs24\lang1031\sbasedon1\snext3 Body Text;}
|
||||
{\s4\sa120\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang1031\loch\f1\fs24\lang1031\sbasedon3\snext4 List;}
|
||||
{\s5\sb120\sa120\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ai\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang1031\i\loch\f1\fs24\lang1031\i\sbasedon1\snext5 caption;}
|
||||
{\s6\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang1031\loch\f1\fs24\lang1031\sbasedon1\snext6 Index;}
|
||||
{\*\cs8\cf0\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang1031\loch\f1\fs24\lang1031 Numbering Symbols;}
|
||||
}{\*\listtable{\list\listtemplateid1
|
||||
{\listlevel\levelnfc0\leveljc0\levelstartat6\levelfollow0{\leveltext \'02\'00.;}{\levelnumbers\'01;}\fi-360\li360}
|
||||
{\listlevel\levelnfc0\leveljc0\levelstartat1\levelfollow0{\leveltext \'03\'00.\'01;}{\levelnumbers\'01\'03;}\fi-360\li720}
|
||||
{\listlevel\levelnfc0\leveljc0\levelstartat1\levelfollow0{\leveltext \'06\'00.\'01.\'02.;}{\levelnumbers\'01\'03\'05;}\fi-360\li1080}
|
||||
{\listlevel\levelnfc0\leveljc0\levelstartat1\levelfollow0{\leveltext \'08\'00.\'01.\'02.\'03.;}{\levelnumbers\'01\'03\'05\'07;}\fi-360\li1440}
|
||||
{\listlevel\levelnfc0\leveljc0\levelstartat1\levelfollow0{\leveltext \'0a\'00.\'01.\'02.\'03.\'04.;}{\levelnumbers\'01\'03\'05\'07\'09;}\fi-360\li1800}
|
||||
{\listlevel\levelnfc0\leveljc0\levelstartat1\levelfollow0{\leveltext \'0c\'00.\'01.\'02.\'03.\'04.\'05.;}{\levelnumbers\'01\'03\'05\'07\'09\'0b;}\fi-360\li2160}
|
||||
{\listlevel\levelnfc0\leveljc0\levelstartat1\levelfollow0{\leveltext \'0e\'00.\'01.\'02.\'03.\'04.\'05.\'06.;}{\levelnumbers\'01\'03\'05\'07\'09\'0b\'0d;}\fi-360\li2520}
|
||||
{\listlevel\levelnfc0\leveljc0\levelstartat1\levelfollow0{\leveltext \'10\'00.\'01.\'02.\'03.\'04.\'05.\'06.\'07.;}{\levelnumbers\'01\'03\'05\'07\'09\'0b\'0d\'0f;}\fi-360\li2880}
|
||||
{\listlevel\levelnfc0\leveljc0\levelstartat1\levelfollow0{\leveltext \'12\'00.\'01.\'02.\'03.\'04.\'05.\'06.\'07.\'08.;}{\levelnumbers\'01\'03\'05\'07\'09\'0b\'0d\'0f\'11;}\fi-360\li3240}
|
||||
{\*\soutlvl{\listlevel\levelnfc0\leveljc0\levelstartat1\levelfollow0{\leveltext \'14\'00.\'01.\'02.\'03.\'04.\'05.\'06.\'07.\'08.\'09.;}{\levelnumbers\'01\'03\'05\'07\'09\'0b\'0d\'0f\'11\'13;}\fi-360\li3600}}\listid1}
|
||||
{\list\listtemplateid2
|
||||
{\listlevel\levelnfc0\leveljc0\levelstartat1\levelfollow0{\leveltext \'02\'00.;}{\levelnumbers\'01;}\fi-360\li360}\listid2}
|
||||
}{\listoverridetable{\listoverride\listid1\listoverridecount0\ls0}{\listoverride\listid2\listoverridecount0\ls1}}
|
||||
|
||||
{\info{\creatim\yr0\mo0\dy0\hr0\min0}{\revtim\yr0\mo0\dy0\hr0\min0}{\printim\yr0\mo0\dy0\hr0\min0}{\comment StarWriter}{\vern3200}}\deftab720
|
||||
{\*\pgdsctbl
|
||||
{\pgdsc0\pgdscuse195\pgwsxn12240\pghsxn15840\marglsxn1800\margrsxn1800\margtsxn1440\margbsxn1440\pgdscnxt0 Standard;}}
|
||||
{\*\pgdscno0}\paperh15840\paperw12240\margl1800\margr1800\margt1440\margb1440\sectd\sbknone\pgwsxn12240\pghsxn15840\marglsxn1800\margrsxn1800\margtsxn1440\margbsxn1440\ftnbj\ftnstart1\ftnrstcont\ftnnar\aenddoc\aftnrstcont\aftnstart1\aftnnrlc
|
||||
\pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs20\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs20\lang1031\loch\f1\fs20\lang1031
|
||||
\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs20\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs20\lang1031\loch\f1\fs20\lang1031
|
||||
\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs20\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs20\lang1031\loch\f1\fs20\lang1031
|
||||
\par \pard\plain {\listtext\pard\plain \li360\ri0\lin360\rin0\fi-360\fs20\fs20\fs20 1.\tab}\ilvl0 \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\ls1\li720\ri0\lin720\rin0\fi-360\rtlch\af1\afs20\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs20\lang1031\loch\f1\fs20\lang1031 {\rtlch \ltrch\loch\f1\fs20\lang1031\i0\b0 \'dcbersicht}
|
||||
\par \pard\plain {\listtext\pard\plain \li360\ri0\lin360\rin0\fi-360\fs20\fs20\fs20 2.\tab}\ilvl0 \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\ls1\li720\ri0\lin720\rin0\fi-360\rtlch\af1\afs20\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs20\lang1031\loch\f1\fs20\lang1031 {\rtlch \ltrch\loch\f1\fs20\lang1031\i0\b0 Installation}
|
||||
\par \pard\plain {\listtext\pard\plain \li360\ri0\lin360\rin0\fi-360\fs20\fs20\fs20 3.\tab}\ilvl0 \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\ls1\li720\ri0\lin720\rin0\fi-360\rtlch\af1\afs20\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs20\lang1031\loch\f1\fs20\lang1031 {\rtlch \ltrch\loch\f1\fs20\lang1031\i0\b0 Regime CLI}
|
||||
\par \pard\plain {\listtext\pard\plain \li360\ri0\lin360\rin0\fi-360\fs20\fs20\fs20 4.\tab}\ilvl0 \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\ls1\li720\ri0\lin720\rin0\fi-360\rtlch\af1\afs20\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs20\lang1031\loch\f1\fs20\lang1031 {\rtlch \ltrch\loch\f1\fs20\lang1031\i0\b0 Ordnerstruktur und Tools}
|
||||
\par \pard\plain {\listtext\pard\plain \li360\ri0\lin360\rin0\fi-360\fs20\fs20\fs20 5.\tab}\ilvl0 \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\ls1\li720\ri0\lin720\rin0\fi-360\rtlch\af1\afs20\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs20\lang1031\loch\f1\fs20\lang1031 {\rtlch \ltrch\loch\f1\fs20\lang1031\i0\b0 Systemstart}
|
||||
\par \pard\plain {\listtext\pard\plain \li360\ri0\lin360\rin0\fi-360\fs20\fs20\fs20 6.\tab}\ilvl0 \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\ls1\li720\ri0\lin720\rin0\fi-360\rtlch\af1\afs20\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs20\lang1031\loch\f1\fs20\lang1031 {\rtlch \ltrch\loch\f1\fs20\lang1031\i0\b0 Programmieren}
|
||||
\par \pard\plain {\listtext\pard\plain \li360\ri0\lin360\rin0\fi-360\fs20\fs20\fs20 \tab}\ilvl0 \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\li720\ri0\lin720\rin0\fi-360\rtlch\af1\afs20\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs20\lang1031\loch\f1\fs20\lang1031 {\rtlch \ltrch\loch\f1\fs20\lang1031\i0\b0 5.1 IOS}
|
||||
\par \pard\plain {\listtext\pard\plain \li360\ri0\lin360\rin0\fi-360\fs20\fs20\fs20 \tab}\ilvl0 \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\li720\ri0\lin720\rin0\fi-360\rtlch\af1\afs20\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs20\lang1031\loch\f1\fs20\lang1031 {\rtlch \ltrch\loch\f1\fs20\lang1031\i0\b0 5.2 Regnatix-Loader}
|
||||
\par \pard\plain {\listtext\pard\plain \li360\ri0\lin360\rin0\fi-360\fs20\fs20\fs20 \tab}\ilvl0 \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\li720\ri0\lin720\rin0\fi-360\rtlch\af1\afs20\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs20\lang1031\loch\f1\fs20\lang1031 {\rtlch \ltrch\loch\f1\fs20\lang1031\i0\b0 5.3 Administra-Code}
|
||||
\par \pard\plain {\listtext\pard\plain \li720\ri0\lin720\rin0\fi-360\fs20\fs20\fs20 \tab}\ilvl1 \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\li1080\ri0\lin1080\rin0\fi-360\rtlch\af1\afs20\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs20\lang1031\loch\f1\fs20\lang1031 {\rtlch \ltrch\loch\f1\fs20\lang1031\i0\b0 5.3.1 SD-Card}
|
||||
\par \pard\plain {\listtext\pard\plain \li720\ri0\lin720\rin0\fi-360\fs20\fs20\fs20 \tab}\ilvl1 \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\li1080\ri0\lin1080\rin0\fi-360\rtlch\af1\afs20\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs20\lang1031\loch\f1\fs20\lang1031 {\rtlch \ltrch\loch\f1\fs20\lang1031\i0\b0 5.3.2 Sound (HSS, Wav, SIDCog)}
|
||||
\par \pard\plain {\listtext\pard\plain \li720\ri0\lin720\rin0\fi-360\fs20\fs20\fs20 \tab}\ilvl1 \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\li1080\ri0\lin1080\rin0\fi-360\rtlch\af1\afs20\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs20\lang1031\loch\f1\fs20\lang1031 {\rtlch \ltrch\loch\f1\fs20\lang1031\i0\b0 5.3.3 LAN}
|
||||
\par \pard\plain {\listtext\pard\plain \li720\ri0\lin720\rin0\fi-360\fs20\fs20\fs20 \tab}\ilvl1 \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\li1080\ri0\lin1080\rin0\fi-360\rtlch\af1\afs20\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs20\lang1031\loch\f1\fs20\lang1031 {\rtlch \ltrch\loch\f1\fs20\lang1031\i0\b0 5.3.4 COM}
|
||||
\par \pard\plain {\listtext\pard\plain \li720\ri0\lin720\rin0\fi-360\fs20\fs20\fs20 \tab}\ilvl1 \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\li1080\ri0\lin1080\rin0\fi-360\rtlch\af1\afs20\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs20\lang1031\loch\f1\fs20\lang1031 {\rtlch \ltrch\loch\f1\fs20\lang1031\i0\b0 5.3.5 I2C}
|
||||
\par \pard\plain {\listtext\pard\plain \li360\ri0\lin360\rin0\fi-360\fs20\fs20\fs20 \tab}\ilvl0 \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\li720\ri0\lin720\rin0\fi-360\rtlch\af1\afs20\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs20\lang1031\loch\f1\fs20\lang1031 {\rtlch \ltrch\loch\f1\fs20\lang1031\i0\b0 5.4 Bellatrix-Code}
|
||||
\par \pard\plain {\listtext\pard\plain \li720\ri0\lin720\rin0\fi-360\fs20\fs20\fs20 \tab}\ilvl1 \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\li1080\ri0\lin1080\rin0\fi-360\rtlch\af1\afs20\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs20\lang1031\loch\f1\fs20\lang1031 {\rtlch \ltrch\loch\f1\fs20\lang1031\i0\b0 5.4.1 Textmodus}
|
||||
\par \pard\plain {\listtext\pard\plain \li720\ri0\lin720\rin0\fi-360\fs20\fs20\fs20 \tab}\ilvl1 \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\li1080\ri0\lin1080\rin0\fi-360\rtlch\af1\afs20\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs20\lang1031\loch\f1\fs20\lang1031 {\rtlch \ltrch\loch\f1\fs20\lang1031\i0\b0 5.4.2 Grafikmodus}
|
||||
\par \pard\plain {\listtext\pard\plain \li720\ri0\lin720\rin0\fi-360\fs20\fs20\fs20 \tab}\ilvl1 \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\li1080\ri0\lin1080\rin0\fi-360\rtlch\af1\afs20\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs20\lang1031\loch\f1\fs20\lang1031 {\rtlch \ltrch\loch\f1\fs20\lang1031\i0\b0 5.4.3 Keyboard und Maus}
|
||||
\par }
|
Binary file not shown.
|
@ -0,0 +1,738 @@
|
|||
''*****************************
|
||||
''* Hydra Sound System v1.2 *
|
||||
''* (C)2007 Andrew Arsenault *
|
||||
''*****************************
|
||||
''http://www.andrewarsenault.com/hss/
|
||||
''e-mail: ym2413a@yahoo.com
|
||||
''
|
||||
'' Cogs used: 2
|
||||
'' HUB-RAM: ~2.7k
|
||||
|
||||
'' Please visit the website for the latest version, documentation, examples and media files.
|
||||
'' Thank you! --Ym2413a
|
||||
|
||||
'' 25.01.2009 Anpassungen für ein komfortableres Interface zur Visualisierung und Steuerung
|
||||
|
||||
CON
|
||||
#0, iEndFlag 'Repeat oder Ende wurde erreicht
|
||||
iRowFlag 'Flag das Songzeile fertig ist
|
||||
iEngineC 'Patternzähler
|
||||
iBeatC 'Beatzähler
|
||||
iRepeat 'zähler für loops
|
||||
#5, iChannel
|
||||
#5, iChannel1
|
||||
#10, iChannel2
|
||||
#15, iChannel3
|
||||
#16, iChannel4
|
||||
#0, iNote
|
||||
iOktave
|
||||
iVolume
|
||||
iEffekt
|
||||
iInstrument
|
||||
|
||||
VAR
|
||||
|
||||
'Interface
|
||||
word intreg[5 * 5]
|
||||
|
||||
'Sound Engine Stack
|
||||
long hsnd_stack[18]
|
||||
long cog1, cog2
|
||||
|
||||
'WavSynth Parameters
|
||||
long snd_regs[48] 'Regs for Sound Hardware (8x6)+5dpcm
|
||||
long dpcm_regs[5]
|
||||
|
||||
'DPCM Command Variables
|
||||
word dpcmreg_ptr
|
||||
|
||||
'Global Hmus Player Vars
|
||||
word tempo
|
||||
word song_pc
|
||||
word song_div
|
||||
word song_ptr
|
||||
word chfre[4]
|
||||
byte chfx[4]
|
||||
byte chvol[4]
|
||||
byte hmus_state
|
||||
byte hmvol
|
||||
byte fxphs
|
||||
|
||||
'Sound FX Variables
|
||||
word runlen[2]
|
||||
word envamp[2]
|
||||
word sfx_ptr[2]
|
||||
byte envphs[2]
|
||||
byte fmcnt[2], fmfreq[2]
|
||||
byte loadsfx[2]
|
||||
|
||||
CON
|
||||
|
||||
'' Hss Master Control
|
||||
|
||||
PUB start: okay
|
||||
|
||||
okay := cog1 := cognew(@entry, @snd_regs)
|
||||
okay := cog2 := cognew(hsound, @hsnd_stack)
|
||||
|
||||
PUB stop
|
||||
|
||||
cogstop(cog2)
|
||||
cogstop(cog1)
|
||||
|
||||
PUB peek(addrptr) : var1
|
||||
|
||||
var1 := LONG[@snd_regs][addrptr]
|
||||
|
||||
PUB intread(index): wert 'interface: auslesen eines interfaceregisters
|
||||
|
||||
wert := intreg[index]
|
||||
|
||||
|
||||
CON
|
||||
|
||||
'' Hydra Music Commands
|
||||
|
||||
PUB hmus_load(songptr) | z
|
||||
|
||||
hmvol := 15
|
||||
song_div := 0
|
||||
song_ptr := songptr
|
||||
song_pc := WORD[songptr][8]
|
||||
tempo := WORD[songptr][12]
|
||||
repeat z from 0 to 3
|
||||
chfx[z] := 0
|
||||
|
||||
repeat z from 0 to 5*5 'interface: playerinterface alle werte löschen
|
||||
intreg[z] := 0
|
||||
|
||||
|
||||
PUB hmus_play
|
||||
|
||||
hmus_state := 1
|
||||
|
||||
PUB hmus_stop | z
|
||||
|
||||
hmus_state := 0
|
||||
repeat z from 0 to 3
|
||||
chvol[z] := 0
|
||||
|
||||
PUB hmus_pause
|
||||
|
||||
hmus_state := 0
|
||||
|
||||
PUB hmus_tempo(var1)
|
||||
|
||||
tempo := var1
|
||||
|
||||
PUB get_hmus_tempo : var1
|
||||
|
||||
var1 := tempo
|
||||
|
||||
PUB hmus_vol(var1)
|
||||
|
||||
hmvol := var1 <# 15 #> 0
|
||||
|
||||
PUB get_hmus_vol : var1
|
||||
|
||||
var1 := hmvol
|
||||
|
||||
CON
|
||||
|
||||
'' FXsynth Commands
|
||||
|
||||
PUB sfx_play(chan, soundptr)
|
||||
|
||||
if(chan == 1)
|
||||
sfx_ptr[0] := soundptr
|
||||
loadsfx[0] := 0
|
||||
if(chan == 2)
|
||||
sfx_ptr[1] := soundptr
|
||||
loadsfx[1] := 0
|
||||
|
||||
PUB sfx_stop(chan)
|
||||
|
||||
if(chan == 1)
|
||||
sfx_ptr[0] := 0
|
||||
if(chan == 2)
|
||||
sfx_ptr[1] := 0
|
||||
|
||||
PUB sfx_keyoff(chan)
|
||||
|
||||
if(chan == 1)
|
||||
envphs[0] := 3
|
||||
if(chan == 2)
|
||||
envphs[1] := 3
|
||||
|
||||
CON
|
||||
|
||||
'' Hydra DPCM Commands
|
||||
|
||||
PUB dpcm_play(soundptr)
|
||||
|
||||
dpcmreg_ptr := soundptr
|
||||
|
||||
PUB dpcm_stop
|
||||
|
||||
dpcmreg_ptr := 1
|
||||
|
||||
CON
|
||||
''*****************************
|
||||
''* Hss Sound Engine *
|
||||
''*****************************
|
||||
PRI Hsound
|
||||
repeat
|
||||
'Update Music Engine
|
||||
UpdateMus(song_ptr, Hmus_state) 'Update Music Player
|
||||
'volume/frequenzwerte werden in die soundregister geschrieben
|
||||
VolumeInterpol 'Delay and Interpolate Volume to Remove Pops and Clicks.
|
||||
|
||||
'Update DPCM Engine
|
||||
if(dpcmreg_ptr)
|
||||
DpcmUpdate 'Update the DPCM registers
|
||||
|
||||
'Update SoundFX Engine
|
||||
|
||||
'FX channel A
|
||||
FXSynth(0,32)
|
||||
'FX channel B
|
||||
FXSynth(1, 40)
|
||||
|
||||
PRI VolumeInterpol | z, channelmul, musvar, freqval
|
||||
|
||||
fxphs += 5
|
||||
|
||||
'Volume Interpolation
|
||||
repeat z from 0 to 3 step 1
|
||||
channelmul := 4+(8*z)
|
||||
musvar := (chvol[z]*(hmvol+1))&$F0
|
||||
snd_regs[channelmul] := (snd_regs[channelmul] & 15)+musvar
|
||||
|
||||
'Freq Interpolation
|
||||
channelmul -= 1 'Jump down a REG to Freq
|
||||
musvar := chfre[z]<<16
|
||||
|
||||
if(chfx[z] == 0) 'None
|
||||
snd_regs[channelmul] := musvar
|
||||
|
||||
elseif(chfx[z] < 3) 'Vibrato (light/hard)
|
||||
if(fxphs < 128)
|
||||
snd_regs[channelmul] := musvar+(chfre[z]<<(7+chfx[z]))
|
||||
else
|
||||
snd_regs[channelmul] := musvar-(chfre[z]<<(7+chfx[z]))
|
||||
|
||||
elseif(chfx[z] == 3) 'Tremolo
|
||||
if(fxphs < 128)
|
||||
snd_regs[channelmul] := musvar
|
||||
else
|
||||
snd_regs[channelmul] := musvar<<1
|
||||
|
||||
else 'Portamento
|
||||
freqval := snd_regs[channelmul]>>16
|
||||
if(freqval & $F000 == chfre[z] & $F000)
|
||||
snd_regs[channelmul] := musvar
|
||||
elseif(freqval < chfre[z])
|
||||
snd_regs[channelmul] := snd_regs[channelmul]+(chfx[z]<<22)
|
||||
else
|
||||
snd_regs[channelmul] := snd_regs[channelmul]-(chfx[z]<<22)
|
||||
|
||||
PRI UpdateMus(songptr, state) | i, channel, channelmul, scrdat, freq, freqoct, flag
|
||||
|
||||
if(state == 0)
|
||||
return ''Song is not playing.
|
||||
|
||||
song_div++ 'zeitfaktor; wird erhöht bis...
|
||||
|
||||
if(song_div => tempo) 'Tempo Divider 'schwellwert erreicht, dann nächster beat
|
||||
song_div := 0
|
||||
flag := 0
|
||||
intreg[iBeatC] := intreg[iBeatC] + 1 'interface: beatconter erhöhen
|
||||
intreg[iRowFlag] := 0 'interface: Kennung das Zeile bearbeitet wird
|
||||
repeat i from 5 to 5*5 'interface: channelwerte löschen
|
||||
intreg[i] := 0
|
||||
|
||||
repeat 'Score Decoder and Processor
|
||||
scrdat := BYTE[song_ptr][song_pc] 'song_pc ist zeiger auf wert in MusicDat
|
||||
channel := scrdat & 3 'untere zwei bit enthalten die kanalnummer
|
||||
channelmul := channel<<3 'jedem channel sind 8 registerwerte zugeordent
|
||||
intreg[iEngineC] := song_pc 'interface: enginecounter setzen
|
||||
song_pc++ 'zeiger auf nächsten wert setzen
|
||||
|
||||
''Base Commands
|
||||
if(scrdat == 0) 'End Row 'nächste trackerzeile
|
||||
intreg[iRowFlag] := 1 'interface: Zeile fertig bearbeitet
|
||||
quit
|
||||
|
||||
if(scrdat == 1) 'Repeat Song 'wiederholt ab MusicLoop (MusicDat ist also die einleitung)
|
||||
song_pc := WORD[songptr][9]
|
||||
intreg[iRepeat] := intreg[iRepeat] + 1 'interface: flag das songende erreicht wurde
|
||||
quit
|
||||
|
||||
if(scrdat == 2) 'End Song 'status wird auf 0 gesetzt
|
||||
intreg[iEndFlag] := 1 'interface: flag das songende erreicht wurde
|
||||
hmus_stop
|
||||
quit
|
||||
|
||||
if(scrdat == 3) 'Set Flag
|
||||
flag := 1
|
||||
next
|
||||
|
||||
if((scrdat & $3C) == $20) 'Patch HI Note 'oktave erhöhen und veränderung zu "Change Note"
|
||||
flag := 2
|
||||
scrdat := scrdat>>3
|
||||
scrdat += 64+channel
|
||||
|
||||
if(scrdat & 4) 'Change Note
|
||||
freq := scrdat>>3 'note Bit3 bis Bit7 (32 Noten)
|
||||
freqoct := freq/12
|
||||
freq -= freqoct*12
|
||||
case flag
|
||||
1 : freqoct += 2
|
||||
2 : freqoct += 6
|
||||
other : freqoct += 4
|
||||
flag := 0
|
||||
snd_regs[4+channelmul] := snd_regs[4+channelmul] & $FE
|
||||
intreg[(channel*iChannel)+iChannel+iNote] := freq + 1 'interface: note setzen (0 ist erste note!)
|
||||
intreg[(channel*iChannel)+iChannel+iOktave] := freqoct 'interface: oktave setzen
|
||||
'frequenz aus tabelle holen
|
||||
'je nach oktave wird nach rechts verschoben (/2)
|
||||
chfre[channel] := NoteFreqs[freq]>>(6-freqoct)
|
||||
snd_regs[4+channelmul] := (snd_regs[4+channelmul] & $FE)+1
|
||||
next 'Repeat To Next Datum
|
||||
|
||||
if(scrdat & 8) 'Change Evelope / Channel Effect
|
||||
if(flag)
|
||||
intreg[(channel*iChannel)+iChannel+iEffekt] := scrdat>>4 + 1 'interface: effektwert setzen
|
||||
chfx[channel] := scrdat>>4
|
||||
flag := 0
|
||||
else
|
||||
intreg[(channel*iChannel)+iChannel+iVolume] := scrdat>>4 'interface: volume setzen
|
||||
chvol[channel] := scrdat>>4
|
||||
next 'Repeat To Next Datum
|
||||
|
||||
if(scrdat & 16) 'Change Instrument
|
||||
freq := (scrdat & $E0)>>3
|
||||
freq += flag<<5
|
||||
flag := 0
|
||||
intreg[(channel*iChannel)+iChannel+iInstrument] := freq>>2 + 1 'interface: instrument setzen
|
||||
snd_regs[0+channelmul] := songptr+WORD[songptr+32][freq] 'zeiger auf neues instrumentensample
|
||||
snd_regs[1+channelmul] := WORD[songptr+32][freq+1] 'ende des samples
|
||||
snd_regs[2+channelmul] := WORD[songptr+32][freq+2] 'loop
|
||||
snd_regs[4+channelmul] := WORD[songptr+32][freq+3] & $0F 'flags?
|
||||
next 'Repeat To Next Datum
|
||||
|
||||
if(scrdat & 64) 'Detune
|
||||
chfre[channel] := chfre[channel]+(chfre[channel]>>8)
|
||||
|
||||
|
||||
|
||||
PRI DpcmUpdate
|
||||
|
||||
if(dpcmreg_ptr > 15) 'Play Sample.
|
||||
dpcm_regs[2] := 65535 'End sample if one was playing
|
||||
dpcm_regs[0] := dpcmreg_ptr+8
|
||||
dpcm_regs[4] := 128
|
||||
dpcm_regs[3] := LONG[dpcmreg_ptr][1] 'Get sampling rate
|
||||
dpcm_regs[1] := WORD[dpcmreg_ptr][1] 'Get length
|
||||
dpcm_regs[2] := 0 'Reset play counter
|
||||
elseif(dpcmreg_ptr == 1) 'Stop Sample
|
||||
dpcm_regs[2] := 65535 'End sample
|
||||
dpcm_regs[4] := 128
|
||||
|
||||
dpcmreg_ptr := 0
|
||||
|
||||
PRI FXSynth(SoundVars, ChannelFX) | TimeCnt, SoundFX, Modwav, FMwav, AMwav
|
||||
TimeCnt := Cnt
|
||||
SoundFX := sfx_ptr[SoundVars]
|
||||
|
||||
if(loadsfx[SoundVars] == 0)
|
||||
'Setup OSC WaveForm
|
||||
case BYTE[SoundFX][0]
|
||||
$00: 'Sine
|
||||
snd_regs[ChannelFX] := @SineTable
|
||||
snd_regs[1+ChannelFX] := 64
|
||||
$01: 'Fast Sine
|
||||
snd_regs[ChannelFX] := @FastSine
|
||||
snd_regs[1+ChannelFX] := 32
|
||||
$02: 'Sawtooth
|
||||
snd_regs[ChannelFX] := @Sawtooth
|
||||
snd_regs[1+ChannelFX] := 64
|
||||
$03: 'Square
|
||||
snd_regs[ChannelFX] := @SqrTable
|
||||
snd_regs[1+ChannelFX] := 32
|
||||
$04: 'Fast Square
|
||||
snd_regs[ChannelFX] := @FastSqr
|
||||
snd_regs[1+ChannelFX] := 8
|
||||
$05: 'Buzz
|
||||
snd_regs[ChannelFX] := @NoteFreqs
|
||||
snd_regs[1+ChannelFX] := 24
|
||||
$06: 'Noise
|
||||
snd_regs[ChannelFX] := $F002
|
||||
snd_regs[1+ChannelFX] := 3000
|
||||
|
||||
snd_regs[2+ChannelFX] := 0
|
||||
snd_regs[4+ChannelFX] := $01
|
||||
|
||||
loadsfx[SoundVars] := 1
|
||||
runlen[SoundVars] := 0
|
||||
fmcnt[SoundVars] := 0
|
||||
fmfreq[SoundVars] := 0
|
||||
envamp[SoundVars] := 0
|
||||
envphs[SoundVars] := 0
|
||||
|
||||
''Modulation Code
|
||||
fmfreq[SoundVars]++
|
||||
if(fmfreq[SoundVars] => BYTE[SoundFX][4])
|
||||
fmfreq[SoundVars] := 0
|
||||
fmcnt[SoundVars]++
|
||||
fmcnt[SoundVars] := fmcnt[SoundVars] & $3F
|
||||
|
||||
case BYTE[SoundFX][5]
|
||||
$00:
|
||||
Modwav := BYTE[@SineTable][fmcnt[SoundVars]]
|
||||
$01:
|
||||
Modwav := BYTE[@FastSine][fmcnt[SoundVars] & 31]
|
||||
$02:
|
||||
Modwav := fmcnt[SoundVars]<<2
|
||||
$03:
|
||||
Modwav := !fmcnt[SoundVars]<<2
|
||||
$04:
|
||||
if(fmcnt[SoundVars] & 8)
|
||||
Modwav := $ff
|
||||
else
|
||||
Modwav := $00
|
||||
$05:
|
||||
Modwav := BYTE[$F002][fmcnt[SoundVars]]
|
||||
$FF:
|
||||
Modwav := BYTE[SoundFX+12][fmcnt[SoundVars] & 15]
|
||||
|
||||
fmwav := Modwav/(BYTE[SoundFX][6]) 'FM amount
|
||||
amwav := 256-(Modwav/(BYTE[SoundFX][7])) 'AM amount
|
||||
amwav := (BYTE[SoundFX][3]*amwav)>>8
|
||||
|
||||
''Envelope Generator
|
||||
if(envphs[SoundVars] == 0) 'Attack
|
||||
envamp[SoundVars] += BYTE[SoundFX][8]
|
||||
if(envamp[SoundVars] > 8191)
|
||||
envamp[SoundVars] := 8191
|
||||
envphs[SoundVars] := 1
|
||||
if(BYTE[SoundFX][8] == $ff)
|
||||
envamp[SoundVars] := 8191
|
||||
if(envphs[SoundVars] == 1) 'Decay
|
||||
envamp[SoundVars] -= BYTE[SoundFX][9]
|
||||
if(envamp[SoundVars] & $8000)
|
||||
envphs[SoundVars] := 2
|
||||
if(envamp[SoundVars] =< (BYTE[SoundFX][10]<<5))
|
||||
envphs[SoundVars] := 2
|
||||
if(envphs[SoundVars] == 2) 'Sustain
|
||||
envamp[SoundVars] := (BYTE[SoundFX][10]<<5)
|
||||
if(envphs[SoundVars] == 3) 'Release
|
||||
envamp[SoundVars] -= BYTE[SoundFX][11]
|
||||
if(envamp[SoundVars] & $8000)
|
||||
envamp[SoundVars] := 4
|
||||
|
||||
amwav := ((envamp[SoundVars]>>9)*(amwav+1))>>4
|
||||
|
||||
''Run Length and Outputing
|
||||
if(SoundFX > 15)
|
||||
runlen[SoundVars]++
|
||||
snd_regs[3+ChannelFX] := (BYTE[SoundFX][2]+fmwav)<<24 'Update Frequency
|
||||
snd_regs[4+ChannelFX] := (amwav<<4)+(snd_regs[4+ChannelFX] & $0F) 'Update Amplitude
|
||||
else
|
||||
snd_regs[4+ChannelFX] := $00 'Mute
|
||||
|
||||
if(BYTE[SoundFX][1] == $ff) '$ff = never stop
|
||||
runlen[SoundVars] := 0
|
||||
|
||||
if(runlen[SoundVars] > (BYTE[SoundFX][1]<<5)) 'Duration KeyOff
|
||||
envphs[SoundVars] := 3
|
||||
|
||||
WaitCnt(TimeCnt + 52_000) ''Delay for Synth Engine Update.
|
||||
|
||||
DAT
|
||||
|
||||
SineTable byte $80, $8c, $98, $a5, $b0, $bc, $c6, $d0
|
||||
byte $da, $e2, $ea, $f0, $f5, $fa, $fd, $fe
|
||||
byte $ff, $fe, $fd, $fa, $f5, $f0, $ea, $e2
|
||||
byte $da, $d0, $c6, $bc, $b0, $a5, $98, $8c
|
||||
byte $80, $73, $67, $5a, $4f, $43, $39, $2f
|
||||
byte $25, $1d, $15, $0f, $0a, $05, $02, $01
|
||||
byte $00, $01, $02, $05, $0a, $0f, $15, $1d
|
||||
byte $25, $2f, $39, $43, $4f, $5a, $67, $73
|
||||
|
||||
Sawtooth byte $ff, $fb, $f7, $f3, $ef, $eb, $e7, $e3
|
||||
byte $df, $db, $d7, $d3, $cf, $cb, $c7, $c3
|
||||
byte $bf, $bb, $b7, $b3, $af, $ab, $a7, $a3
|
||||
byte $9f, $9b, $97, $93, $8f, $8b, $87, $83
|
||||
byte $80, $7c, $78, $74, $70, $6c, $68, $64
|
||||
byte $60, $5c, $58, $54, $50, $4c, $48, $44
|
||||
byte $40, $3c, $38, $34, $30, $2c, $28, $24
|
||||
byte $20, $1c, $18, $14, $10, $0c, $08, $04
|
||||
|
||||
FastSine byte $80, $98, $b0, $c6, $da, $ea, $f5, $fd
|
||||
byte $ff, $fd, $f5, $ea, $da, $c6, $b0, $98
|
||||
byte $80, $67, $4f, $39, $25, $15, $0a, $02
|
||||
byte $00, $02, $0a, $15, $25, $39, $4f, $67
|
||||
|
||||
SqrTable byte $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff
|
||||
byte $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff
|
||||
byte $00, $00, $00, $00, $00, $00, $00, $00
|
||||
byte $00, $00, $00, $00, $00, $00, $00, $00
|
||||
|
||||
FastSqr byte $ff, $ff, $ff, $ff, $00, $00, $00, $00
|
||||
|
||||
'Note LookupTable.
|
||||
NoteFreqs word $85F3, $8DEA, $965B, $9F4B, $A8C4, $B2CD, $BD6F, $C8B3, $D4A2, $E147, $EEAC, $FCDE 'Top Octave Lookup
|
||||
|
||||
CON
|
||||
''*****************************
|
||||
''* WaveTable Synth v1.2 *
|
||||
''* DPCM Synth v1.1 *
|
||||
''* (C)2006 Andrew Arsenault *
|
||||
''*****************************
|
||||
DAT
|
||||
org
|
||||
entry mov dira,Port_Pins 'Setup output pins
|
||||
|
||||
mov ctra,Right_ctra 'Setup Right Audio Channel
|
||||
mov ctrb,Left_ctra 'Setup Left Audio Channel
|
||||
|
||||
mov ChlA_wave,#256 'Set channel signals.
|
||||
mov ChlA_offset,#0 'Set channel's offset.
|
||||
mov ChlA_counter,#0
|
||||
|
||||
mov Time,#10
|
||||
add Time,cnt 'Prepare for asm type WAITCNT loop.
|
||||
|
||||
'MAIN LOOP
|
||||
update waitcnt Time,Timing_delay 'Wait for CNT = D, then add S into D
|
||||
|
||||
'Transfer Sound Registers
|
||||
mov addrregs,par
|
||||
mov y,NumberOfChannels
|
||||
|
||||
'Fetch Channel's Registers
|
||||
transferchl rdlong ChlAp_sampptr,addrregs
|
||||
add addrregs,#4
|
||||
rdlong ChlAp_sampend,addrregs
|
||||
add addrregs,#4
|
||||
rdlong Ch1Ap_samplpp,addrregs
|
||||
add addrregs,#4
|
||||
rdlong Ch1Ap_freq,addrregs
|
||||
add addrregs,#4
|
||||
rdlong ChlAp_keyon,addrregs
|
||||
|
||||
'Fetch Channel's Static Variables
|
||||
add addrregs,#8
|
||||
rdlong ChlA_offset,addrregs
|
||||
add addrregs,#4
|
||||
rdlong ChlA_counter,addrregs
|
||||
|
||||
'Run Synth Engine on Channel
|
||||
call #wvsynth
|
||||
|
||||
'Store Channel's Static Variables (Tucked Center X move to Wave)
|
||||
wrlong ChlA_counter,addrregs
|
||||
sub addrregs,#4
|
||||
sub x,#256
|
||||
wrlong ChlA_offset,addrregs
|
||||
sub addrregs,#4
|
||||
mov ChlA_wave,x 'Doesn't Waste anything doing this.
|
||||
wrlong ChlA_wave,addrregs
|
||||
add addrregs,#12
|
||||
|
||||
'Loop Until All Channel's Are Done.
|
||||
djnz y,#transferchl
|
||||
|
||||
'Run DPCM Engine
|
||||
call #dpcm
|
||||
|
||||
'Mix Channels Together
|
||||
mov addrregs,par
|
||||
mov ChlA_wave,#0
|
||||
add addrregs,#5*4
|
||||
mov y,NumberOfChannels
|
||||
|
||||
mixchls rdlong x,addrregs
|
||||
add ChlA_wave,x
|
||||
add addrregs,#8*4
|
||||
djnz y,#mixchls
|
||||
|
||||
mov x,DPCM_wave 'Add DPCM
|
||||
shl x,#2
|
||||
add ChlA_wave,x
|
||||
|
||||
shl ChlA_wave,#20 'Convert 12bit singal into a 32bit one.
|
||||
|
||||
'Update output Channels then repeat again.
|
||||
mov frqa,ChlA_wave
|
||||
mov frqb,ChlA_wave
|
||||
|
||||
jmp #update
|
||||
|
||||
|
||||
|
||||
|
||||
'-------------------------Dpcm Engine-------------------------'
|
||||
|
||||
dpcm mov addrregs,par
|
||||
add addrregs,#192
|
||||
|
||||
rdlong DPCM_address,addrregs 'Start Address
|
||||
add addrregs,#4
|
||||
rdlong DPCM_runlen,addrregs 'File Lenght
|
||||
add addrregs,#4
|
||||
rdlong DPCM_offset,addrregs 'File Offset
|
||||
add addrregs,#4
|
||||
rdlong DPCM_freq,addrregs 'Playback Speed
|
||||
add addrregs,#4
|
||||
rdlong DPCM_wave,addrregs 'Waveform Amp
|
||||
|
||||
'Check for if keyon/length is set.
|
||||
cmp DPCM_offset,DPCM_runlen wc
|
||||
if_ae jmp #mute_dpcm 'End of file
|
||||
|
||||
'Freq Timer/Divider and Increase sampling offset
|
||||
add DPCM_counter,DPCM_freq wc
|
||||
if_nc jmp #done_dpcm
|
||||
|
||||
'Decode DPCM
|
||||
add DPCM_address,DPCM_offset
|
||||
rdbyte x,DPCM_address 'Fetch Datum
|
||||
|
||||
mov DPCM_delta,x
|
||||
shr DPCM_delta,#6
|
||||
mov y,#1
|
||||
shl y,DPCM_delta
|
||||
mov DPCM_delta,y
|
||||
|
||||
mov y,#1
|
||||
shl y,DPCM_phs
|
||||
test x,y wc
|
||||
if_c add DPCM_wave,DPCM_delta
|
||||
if_nc sub DPCM_wave,DPCM_delta
|
||||
|
||||
add DPCM_phs,#1
|
||||
cmp DPCM_phs,#6 wc
|
||||
if_b jmp #done_dpcm
|
||||
|
||||
mov DPCM_phs,#0
|
||||
add DPCM_offset,#1
|
||||
jmp #done_dpcm
|
||||
|
||||
mute_dpcm mov DPCM_wave, #128
|
||||
|
||||
done_dpcm mov addrregs,par
|
||||
add addrregs,#200
|
||||
wrlong DPCM_offset,addrregs 'File Offset
|
||||
add addrregs,#8
|
||||
wrlong DPCM_wave,addrregs 'Wave
|
||||
dpcm_ret ret
|
||||
|
||||
'-----------------------Dpcm Engine End-----------------------'
|
||||
|
||||
|
||||
|
||||
'-------------------------Sound Engine-------------------------'
|
||||
|
||||
'Freq Timer/Divider and Increase sampling offset
|
||||
wvsynth add ChlA_counter,Ch1Ap_freq wc
|
||||
if_c add ChlA_offset,#1
|
||||
|
||||
'Reset sample position and lock at zero if Keyoff.
|
||||
test ChlAp_keyon,#%0001 wc
|
||||
if_nc mov ChlA_offset,#0
|
||||
|
||||
'Reset(loop) if needed
|
||||
cmp ChlA_offset,ChlAp_sampend wc
|
||||
if_ae mov ChlA_offset,Ch1Ap_samplpp
|
||||
|
||||
'Check BitRate and Set Offset
|
||||
mov x,ChlA_offset
|
||||
test ChlAp_keyon,#%0010 wc
|
||||
if_c shr x,#1
|
||||
|
||||
'Fetch WaveTable
|
||||
mov ChlA_wave,ChlAp_sampptr
|
||||
add ChlA_wave,x
|
||||
rdbyte ChlA_wave,ChlA_wave
|
||||
|
||||
'Check BitRate and Skip if 8bit
|
||||
test ChlAp_keyon,#%0010 wc
|
||||
if_nc jmp #skip_4bitsam
|
||||
|
||||
'Convert 4bit to 8bit
|
||||
test ChlA_offset,#%0001 wc
|
||||
if_c shr ChlA_wave,#4
|
||||
if_nc and ChlA_wave,#%00001111
|
||||
|
||||
mov x,ChlA_wave
|
||||
shl ChlA_wave,#4
|
||||
add ChlA_wave,x
|
||||
|
||||
'Center Amplitude and mute if Keyoff.
|
||||
skip_4bitsam test ChlAp_keyon,#%0001 wc
|
||||
if_nc mov ChlA_wave,#128
|
||||
|
||||
'Volume Multiply
|
||||
mov x,#0
|
||||
test ChlAp_keyon,#%10000000 wc
|
||||
if_c add x,ChlA_wave
|
||||
if_nc add x,#128
|
||||
|
||||
shr ChlA_wave,#1
|
||||
test ChlAp_keyon,#%01000000 wc
|
||||
if_c add x,ChlA_wave
|
||||
if_nc add x,#64
|
||||
add x,#64
|
||||
|
||||
shr ChlA_wave,#1
|
||||
test ChlAp_keyon,#%00100000 wc
|
||||
if_c add x,ChlA_wave
|
||||
if_nc add x,#32
|
||||
add x,#96
|
||||
|
||||
shr ChlA_wave,#1
|
||||
test ChlAp_keyon,#%00010000 wc
|
||||
if_c add x,ChlA_wave
|
||||
if_nc add x,#16
|
||||
add x,#112
|
||||
|
||||
'Return Audio as X.
|
||||
wvsynth_ret ret
|
||||
|
||||
'-----------------------Sound Engine End-----------------------'
|
||||
|
||||
Port_Pins long %00000000_00000000_00000011_00000000
|
||||
|
||||
'- CTR PLL -------- BPIN --- APIN
|
||||
Right_ctra long %0_00110_000_00000000_000000_000_001000
|
||||
Left_ctra long %0_00110_000_00000000_000000_000_001001
|
||||
|
||||
Timing_delay long 2500 'Sampling Rate = 32,000.00hz
|
||||
NumberOfChannels long 6
|
||||
|
||||
Time res 1
|
||||
addrregs res 1
|
||||
x res 1
|
||||
y res 1
|
||||
|
||||
'WaveTable Synth Accumulators
|
||||
ChlA_wave res 1
|
||||
ChlA_offset res 1
|
||||
ChlA_counter res 1
|
||||
ChlAp_sampptr res 1
|
||||
ChlAp_sampend res 1
|
||||
Ch1Ap_samplpp res 1
|
||||
Ch1Ap_freq res 1
|
||||
ChlAp_keyon res 1
|
||||
|
||||
'DPCM Accumulators
|
||||
DPCM_wave res 1
|
||||
DPCM_address res 1
|
||||
DPCM_offset res 1
|
||||
DPCM_counter res 1
|
||||
DPCM_freq res 1
|
||||
DPCM_runlen res 1
|
||||
DPCM_phs res 1
|
||||
DPCM_delta res 1
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,82 @@
|
|||
{\rtf1\ansi\ansicpg1252\deff0\deftab709{\fonttbl{\f0\fnil\fcharset0 Times New Roman;}{\f1\fnil\fcharset128 Times New Roman;}{\f2\fnil\fcharset0 Courier New;}{\f3\fnil\fcharset2 Symbol;}}
|
||||
{\*\generator Msftedit 5.41.15.1515;}\viewkind4\uc1\pard\lang1031\f0\fs20 18-09-2010-dr235\tab\tab - regime: free zeigt jetzt auch die speicherbelegung des eram an\par
|
||||
\tab\tab\tab - speicherverwaltung/ramdisk integriert (beispielcode siehe eram.spin & regime.spin)\par
|
||||
\tab\tab\tab - eram.bin kann jetzt auch mit ramdisk umgehen\par
|
||||
\tab\tab\tab - regime: neue kommandos f\'fcr ramdisk\par
|
||||
\tab\tab\tab - egalisierung der namen f\'fcr den ramzugriff (\'e4lterer code mu\'df leicht angepasst werden)\par
|
||||
\tab\tab\tab - user- und systemmode f\'fcr ramzugriff eingef\'fcgt\par
|
||||
\tab\tab\tab - erste version eine make-batch um das gesamte system zu kompilieren (nur grundsystem)\par
|
||||
\tab\tab\tab - \'e4nderung zur ios: da bst eine pfadliste zu bibliotheksordnern unterst\'fctzt, liegt (soweit das m\'f6glich ist)\par
|
||||
\tab\tab\tab die ios nun nur noch unter system\\regnatix \par
|
||||
\tab\tab\tab WICHTIG: Pfad zur ios.spin im bst einstellen\par
|
||||
23-08-2010-dr040\tab\tab - integration ay-emulator (admay.adm) und yplay\f1\par
|
||||
19-07-2010-dr235 \f0\tab\f1 - booten eines alternativen administra-codes: befindet sich auf der karte\par
|
||||
\f0\tab\tab \f1 in der root eine datei "adm.sys", so wird diese datei automatisch in\par
|
||||
\f0\tab\tab \f1 administra geladen\par
|
||||
11-07-2010-dr235\tab\f0\tab\f1 - integration sid1/2-funktionen in admsid/ios\line\tab\tab\tab - anpassung sid-demo von ahle2 als regnatix-code (verzeichnis demo)\line\tab\tab\tab - diverse graphics-spielereien (verzeichnis demo)\line\tab\tab\tab - sysconf /af - administra neu booten (admflash.adm\line\tab\tab\tab wird dadurch \u252?berfl\u252?ssig)\line 27-06-2010-dr085/235\tab - admin mountet nun automatisch nach einem boot\tab\tab\line 26-06-2010-dr235\tab\f0\tab\f1 - div. demos zugef\u252?gt\line\tab\tab\tab - shooter angepasst und eingef\u252?gt\line 20-06-2010-dr235\tab\f0\tab\f1 - erste lauff\u228?hige SID-Player-Version\line\tab\tab\tab f\u252?r die Kommandozeile (splay)\line 14-06-2010-dr085/235\tab - Semaphoren in FATEngine korrekt eingesetzt\line\tab\tab\tab - Abfrage des Volume-Labels korrigiert\line 10-06-2010-dr235\tab\f0\tab\f1 - Kommando "ramtest" zugef\u252?gt\line 09-06-2010-dr085\tab\f0\tab\f1 - Fehler in Administra-Bootfunktion behoben\line\line -----------------------------------------------------------------------------------------------\line\line\f0 02-10-2010-dr235\par
|
||||
\par
|
||||
\ul\b Speicherverwaltung:\par
|
||||
\ulnone\b0\par
|
||||
In dieser Version ist eine erste Beta-Version der Speicherverwaltung des externen RAM's enthalten. Der Speicher kann dabei in einem einfachen oder einem strukturierten Modus verwendet werden. Klingt kompliziert, ist aber ganz einfach. \par
|
||||
\par
|
||||
\b Einfacher Modus:\par
|
||||
\b0\par
|
||||
Hierbei kann ein Programm auf den eRAM \'fcber die IOS-Routinen ios.ram_* zugreifen. Wahlweise kann der Speicher im Systemmode direkt von 0 bis $07FFFF angesprochen werden, oder nur der Userbereich. Im Systemmodus ist darauf zu achten, dass eine eventuell vorhandene Ramdisk und die Systemvariablen nicht \'fcberschrieben werden, man sollte also wissen was man tut... ;) Die Ramdisk wird ab der physischen Adresse 0 als verkettete Liste verwaltet, die Systemvariablen befinden sich ab $07FFFF abw\'e4rts. \par
|
||||
\par
|
||||
ios.ram_wrbyte(ios#sysmod,0,ios#MAGIC)\tab\tab - Schreibt den Wert 0 in die Systemvariable, um einen Kaltstart auszul\'f6sen.\par
|
||||
ios.ram_wrbyte(ios#sysmod,$20,$100)\tab\tab - Schreibt den Wert $20 an die physische Adresse $100 im eRAM.\par
|
||||
\par
|
||||
Da es nun m\'fchsam ist in einem kleinen Code solche Konflikte mit dem Systemspeicher zu vermeiden, gibt es den Usermodus. Im Usermodus wird nur genau jener freie Speicher adressiert, welcher sich zwischen Ramdisk und Systemvariablen befindet. In diesem Fall ist die Adressierung also virtualisiert.\par
|
||||
\par
|
||||
ios.ram_wrbyte(ios#usrmod,0,$100)\tab\tab - Schreibt den Wert 0 an die Adresse $100 im Userspeicher!\par
|
||||
\par
|
||||
In Regime kann man mit dem Kommando "free" jetzt auch die wichtigsten Systemvariablen der Speicherverwaltung anzeigen.\par
|
||||
\par
|
||||
RBAS\tab\tab - Erste physische Adresse des Userspeichers\par
|
||||
REND\tab\tab - Physische Adresse der letzten freien Speicherstelle des Userspeichers.\par
|
||||
USER\tab\tab - Gr\'f6sse des Userspeichers (REND - RBAS).\par
|
||||
RAMDRV\tab 0 - Ramdisk ist nicht initialisiert\par
|
||||
\tab\tab 1 - Ramdisk ist initialisiert\par
|
||||
SYSVAR\tab - Erste physische Adresse der Systemvariablen.\par
|
||||
\par
|
||||
Noch genauer kann man sich die Speicherbelegung mit dem Tool "eram" anschauen. Nur ein paar Beispiele:\par
|
||||
\par
|
||||
d\tab - Anzeige des Speichers. Es werden zwei Adressspalten angezeigt. Die zweite schwarze Adresse in jeder Zeile zeigt die physische Adresse, die erste gr\'fcne Adresse die virtuelle Adresse im Userspeicher. Man kann sehr gut erkennen, ab welcher Adrese der Userbereich anf\'e4ngt und wo er endet.\par
|
||||
d 100\tab - Anzeige ab physischer Adresse $100\par
|
||||
d bas\tab - Anzeige vom Start des Userspeichers.\par
|
||||
n \tab - Anzeige inkrementell fortsetzen\par
|
||||
\par
|
||||
Die Nutzung des Userspeichers ist sehr einfach. Es sind dabei nur folgende Regeln zu beachten:\par
|
||||
\par
|
||||
\pard{\pntext\f3\'B7\tab}{\*\pn\pnlvlblt\pnf3\pnindent0{\pntxtb\'B7}}\fi-720\li720 Man muss selbst darauf achten die Speichergrenzen nicht zu \'fcberschreiten. Bei \'dcberschreitung kann aber nichts passieren - die IOS-Routinen brechen einfach ab, allerdings werden die eigenen Daten halt nicht korrekt verarbeitet. Es werden also die Systemvariablen und die Daten in der Ramdisk gesch\'fctzt.\par
|
||||
{\pntext\f3\'B7\tab}Der Userbereich im eRAM ist nur zur Laufzeit der Anwendung g\'fcltig. Wird die Anwendung beendet, so kann durch Regime oder eine andere Anwendung mit den Daten der Ramdisk gearbeitet werden, wodurch sich der physische Bereich des Userbereiches ver\'e4ndert. Wer also residente Daten \'fcber die Laufzeit der Anwendung hinaus braucht, muss im strukturierten Modus mit der Ramdisk arbeiten.\par
|
||||
{\pntext\f3\'B7\tab}In einer Anwendung nicht den einfachen oder strukturierten Modus mischen - das gibt Chaos, wenn man nicht ganz genau aufpasst\par
|
||||
\pard\par
|
||||
Ansonsten kann man wie gehabt die schon bekannten IOS-Routinen verwenden, einzig der \'dcbergabeparameter zur Wahl des System- oder Usermodus sind hinzugekommen. Als Beispiel kann man sich die Soundplayer anschauen, die ihre Dateiliste im Userspeicher ablegen.\par
|
||||
\par
|
||||
\b Strukturierter Modus:\b0\par
|
||||
\par
|
||||
Was ist aber, wenn wir einen kleinen Texteditor schreiben wollen, der seine Textdaten resident im eRAM speichern kann? Ich m\'f6chte also den Texteditor verlassen k\'f6nnen, um in Regime zum Beispiel einen Assembler aufzurufen, welcher den Text dann assembliert. Darauf folgend m\'f6chte ich meinen Texteditor wieder starten und an dem Text weiter arbeiten. Daf\'fcr muss es meiner Anwendung - dem Textprogramm - m\'f6glich sein, einen Speicherbereich im eRAM zu reservieren, der von System und anderen Anwendungen respektvoll behandelt wird.\par
|
||||
\par
|
||||
Gedacht, getan: Im strukturierten Modus wird der Speicher in Form einer Ramdisk verwaltet. Die Dateien/Daten k\'f6nnen \'fcber ihren Namen angesprochen werden. Es kann mit put & get sequentiell, oder mit read & write direkt adressierbar auf die Daten in der Datei zugegriffen werden.\par
|
||||
\par
|
||||
Als erstes praktisches Beispiel m\'f6gen die neuen Kommandos in Regime selbst dienen, mit denen man die Ramdisk verwalten kann:\par
|
||||
Neue Regime-Kommandos:\par
|
||||
\par
|
||||
\f2 xload <sd:fn> - datei in ram laden\par
|
||||
xsave <x:fn> - datei aus ram speichern\par
|
||||
xdir - verzeichnis im ram anzeigen\par
|
||||
xrename <x:fn1> <x:fn2> - datei im ram umbenennen\par
|
||||
xdel <x:fn> - datei im ram l\'f6schen\par
|
||||
xtype <x:fn> - text im ram anzeigen\par
|
||||
\f0\par
|
||||
So ist es also m\'f6glich, sich in der Kommandozeile anzuschauen, welche residenten Daten die Programme aktuell angelegt haben. Sofern es Textdaten sind, k\'f6nnen diese Daten auch einafch angezeigt werden.\par
|
||||
\par
|
||||
Die Speicherverwaltung ist allerdings noch sehr experimentell - was bedeutet, dass wohl noch einige Bugs drin sein d\'fcrften. :)\par
|
||||
\par
|
||||
\ul\b MAKE.BAT\par
|
||||
\par
|
||||
\ulnone\b0 Diese Batchdatei im obersten Verzeichnis kompiliert das Grundsystem, bestehend aus den drei Flashdateien und den grundlegenden Kommandos im Systemverzeichnis. Ist ein erster Versuch. Was noch fehlt ist ein Fehlerlog und vielleicht noch die anderen Programme.\par
|
||||
\f1\line 09-06-2010-dr235\line\line Nach nur zwei Tagen hat drohne085 (frida) das Geheimnis um die Bootroutine gel\u246?st: Die Ursache lag in einer von der FATEngine verwendeten Semaphore, welche fest auf den Lock 0 "verdrahtet" war. Diese Semaphore wird an diversen Stellen in der Engine verwendet, wurde aber beim Bootvorgang nicht gel\u246?scht oder freigegeben! Gedacht war sie, um den Bus zur SD-Card bei einem Zugriff zu verriegeln, falls mehrere Instanzen der Engine laufen, und gleichzeitig zugreifen wollen. Somit hat sich die Engine quasi selbst verriegelt und nach dem Bootvorgang als "neue Instanz" nun auch keinen Zugriff mehr - so sch\u246?n kann praktische Parallelverarbeitung sein... ;)\line\line Hier nun eine neue und aktuelle Version mit einer tempor\u228?ren funktionierenden L\u246?sung des Problems.\line\line Im System-Ordner gibt es jetzt folgende ausf\u252?hrbare Administra-Dateien:\line\line admflash.adm\tab\tab Standard-Flash, welches auch im EEProm gespeichert ist\line admini.adm\tab\tab Mini-Flash ohne Sound, nor SDCard + Managment-Routinen\line admled.adm\tab\tab Das Heartbeat-LED-Testprogramm zum direkten laden\line aterm96.adm\tab\tab Die leicht modifizierte Kommandozeile vom Programmierer der FATEngine. Mit \line\tab\tab\tab diesem Administra-Code kann man direkt \u252?ber die Hostschnittstelle (9600 Baud)\line\tab\tab\tab mit dem Chip kommunizieren. Dokumentation der Kommandos findet man im \line\tab\tab\tab Verzeichnis "komponenten/fat/fatengine beta"\line \line\line 07-06-2010-dr235\line\line Hier der aktuelle Stand von TriOS. Momentan k\u228?mpfe ich an einem \line Komplexfehler mit dem Bootloader von Administra. Das Problem ist recht \line einfach zu reproduzieren, aber leider (f\u252?r mich) nur schwer zu\line erfasen: Die verwendete FATEngine besitzt eine Bootfunktion um einen\line neuen BIN-Objektcode in den Propeller zu laden. Dieser Code funktioniert \line auch teilweise. So kann man das Administra-Bios selbst laden und dann\line auch per Regime-Kommandos verwenden: Die Kommandos "cogs" und "sysinfo"\line sprechen Administra-Funktionen an, welche auch korrekt ausgef\u252?hrt werden.\line Das Problem: Nach dem Bootprozess kann man keine SD-Card mehr mounten.\line\line Es ist auch m\u246?glich den Fehler noch weiter einzugrenzen: Wenn man die \line originale FATEngine (im Verzeichnis komponenten/fat) vom Host direkt in \line Administra startet, meldet sich diese in Form einer einfachen Kommando-\line zeile per Hostschnittstelle. Versucht man dort eine erzeugte BIN-Datei\line genau dieser Kommandozeile (demo.spin) zu booten, so hat man das gleiche\line Ergebnis.\line\line Verzeichnisstruktur:\line\line bin\tab\tab\tab - BIN-Dateien f\u252?r die Flash's und die SD-Card\line doku\tab\tab\tab - \line flash\tab\tab\tab - Quelltexte f\u252?r die Software in den EEProms\line system\tab\tab\tab - Quelltext f\u252?r ausf\u252?hrbare BIN-Dateien\line zubeh\u246?r\tab\tab\tab - Kleine Zusatzprogramme (StarTracker, Boulder Dash...)\line komponenten\tab\tab - Div. verwendete Objekte (FATEngine, SIDCog...)\line\line Installation:\line\line 1. \tab Flashen der drei EEProms mit den BIN-Dateien aus "bin/flash" oder\line\tab\u252?ber das Propellertool aus den Quellen "flash".\line\line 2. \tab SD-Card erstellen: Einfach alles aus "bin/sd-card" auf eine FAT16/32\line\tab Karte kopieren.\line\line Das System bootet Regnatix und Bellatrix beim Systemstart aus den Dateien\line\f0 "adm.sys", \f1 "reg.sys" bzw. "bel.sys". Diese Dateien k\u246?nnen auch das Hidden-Bit gesetzt\line haben. Externe Kommandos bzw. ausf\u252?hrbare BIN-Dateien werden im aktuellen\line UND im System-Verzeichnis gesucht - alle Systemkommandos k\u246?nnen also in das \line System-Verzeichnis kopiert werden.\line\line Hilfe gibt es meist \u252?ber das Kommando "help" oder den Parameter "/h".\line\line\tab\line\line\par
|
||||
}
|
||||
|