Skip to content
Browse files

Pattern memory rotated 180*

Added defines for flipping X/Y, machine.h
  • Loading branch information...
1 parent 27c7b2a commit 30f3ac0d3bcf914f5fed870703011a2327d3fe8f @stg committed Aug 5, 2012
Showing with 21 additions and 6 deletions.
  1. BIN bin-win/gui.exe
  2. +15 −0 lib/include/machine.h
  3. +3 −3 lib/src/m_kh930.c
  4. +3 −3 lib/src/m_kh940_950.c
View
BIN bin-win/gui.exe
Binary file not shown.
View
15 lib/include/machine.h
@@ -10,6 +10,21 @@
extern "C" {
#endif
+#define FLIPX
+//#define FLIPY
+
+#ifdef FLIPX
+#define XCAL(X,W) (((W)-1)-(X))
+#else
+#define XCAL(X,W) (X)
+#endif
+
+#ifdef FLIPY
+#define YCAL(Y,H) (((H)-1)-(Y))
+#else
+#define YCAL(Y,H) (Y)
+#endif
+
// pattern info
typedef struct {
uint16_t id;
View
6 lib/src/m_kh930.c
@@ -66,7 +66,7 @@ static void decode_pattern(ptndesc_t *p_desc,uint8_t *p_image) {
for(x=0;x<p_desc->width;x++) {
sample=(nib_get(p_track,nptrd-(x>>2))&(1<<(x&3)))?nib_get(p_track,nptrm-y):0xFF;
if(sample>0x1&&sample<0xF) sample--;
- image_pset(p_image,p_desc->width,x,p_desc->height-(1+y),sample);
+ image_pset(p_image,p_desc->width,XCAL(x,p_desc->width),YCAL(y,p_desc->height),sample);
}
nptrd+=stride;
}
@@ -209,7 +209,7 @@ static uint16_t add_pattern(uint8_t *p_image,uint16_t w,uint16_t h) {
memset(p_memory,0,memo_bytes);
for(y=0;y<h;y++) {
for(x=0;x<w;x++) {
- sample=image_sample(p_image,w,x,h-(y+1));
+ sample=image_sample(p_image,w,XCAL(x,w),YCAL(y,h));
if(sample!=0xFF) {
nib_set(p_memory,(memo_bytes<<1)-(y+1),sample);
break;
@@ -238,7 +238,7 @@ static uint16_t add_pattern(uint8_t *p_image,uint16_t w,uint16_t h) {
// calculate index of the current bit
bp_this=bp_line-x;
// sample image
- if(image_sample(p_image,w,x,h-(y+1))!=0xFF) bit_set(p_memory,bp_this);
+ if(image_sample(p_image,w,XCAL(x,w),YCAL(y,h))!=0xFF) bit_set(p_memory,bp_this);
}
}
// insert into memory @ PATTERN_PTR1
View
6 lib/src/m_kh940_950.c
@@ -66,7 +66,7 @@ static void decode_pattern(ptndesc_t *p_desc,uint8_t *p_image) {
for(x=0;x<p_desc->width;x++) {
sample=(nib_get(p_track,nptrd-(x>>2))&(1<<(x&3)))?nib_get(p_track,nptrm-y):0xFF;
if(sample>0x1&&sample<0xF) sample--;
- image_pset(p_image,p_desc->width,x,p_desc->height-(1+y),sample);
+ image_pset(p_image,p_desc->width,XCAL(x,p_desc->width),YCAL(y,p_desc->height),sample);
}
nptrd+=stride;
}
@@ -162,7 +162,7 @@ static uint16_t add_pattern(uint8_t *p_image,uint16_t w,uint16_t h) {
memset(p_memory,0,memo_bytes);
for(y=0;y<h;y++) {
for(x=0;x<w;x++) {
- sample=image_sample(p_image,w,x,h-(y+1));
+ sample=image_sample(p_image,w,XCAL(x,w),YCAL(y,h));
if(sample!=0xFF) {
nib_set(p_memory,(memo_bytes<<1)-(y+1),sample);
break;
@@ -191,7 +191,7 @@ static uint16_t add_pattern(uint8_t *p_image,uint16_t w,uint16_t h) {
// calculate index of the current bit
bp_this=bp_line-x;
// sample image
- if(image_sample(p_image,w,x,h-(y+1))!=0xFF) bit_set(p_memory,bp_this);
+ if(image_sample(p_image,w,XCAL(x,w),YCAL(y,h))!=0xFF) bit_set(p_memory,bp_this);
}
}
// insert into memory @ PATTERN_PTR1

0 comments on commit 30f3ac0

Please sign in to comment.
Something went wrong with that request. Please try again.